diff options
-rw-r--r-- | URPM.xs | 8 | ||||
-rw-r--r-- | t/parse.t | 8 |
2 files changed, 12 insertions, 4 deletions
@@ -3666,13 +3666,15 @@ Urpm_spec2srcheader(specfile) pkg = (URPM__Package)malloc(sizeof(struct s_Package)); memset(pkg, 0, sizeof(struct s_Package)); pkg->h = headerLink(spec->sourceHeader); - EXTEND(SP, 1); sv_pkg = sv_newmortal(); sv_setref_pv(sv_pkg, "URPM::Package", (void*)pkg); - PUSHs(sv_pkg); + XPUSHs(sv_pkg); spec = freeSpec(spec); } else { - PUSHs(&PL_sv_undef); + XPUSHs(&PL_sv_undef); + /* apparently rpmlib sets errno this when given a bad spec. */ + if (errno == EBADF) + errno = 0; } ts = rpmtsFree(ts); @@ -4,7 +4,7 @@ use strict; use warnings; -use Test::More tests => 27; +use Test::More tests => 28; use MDV::Packdrakeng; use URPM; use URPM::Build; @@ -72,4 +72,10 @@ ok(URPM::rpmvercmp("1:1-1mdk", "2:1-1mdk") == -1, "epoch 1 vs 2 = -1"); ok($pkg->get_tag(1000) eq 'test-rpm', 'parsed correctly'); $pkg = URPM::spec2srcheader("doesnotexist.spec"); ok(!defined $pkg, "non-existent spec"); + open my $f, '>', 'bad.spec' or die "Can't write bad.spec: $!\n"; + print $f "Name: foo\nVerssion: 2\n"; + close $f; + $pkg = URPM::spec2srcheader("bad.spec"); + ok(!defined $pkg, "bad spec"); + END { unlink "bad.spec" } } |