aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@gmail.com>2015-02-26 21:42:41 +0000
committerPascal Terjan <pterjan@gmail.com>2015-02-26 21:42:41 +0000
commit28d84b5486cfd87c5e9882d552367408e30bbb42 (patch)
treef7b7458551b0ea42d76b2ff6665314a9fa31d836
parent398f2c1317745e2a94c0a46fc2eb223f483b039c (diff)
downloadperl-URPM-28d84b5486cfd87c5e9882d552367408e30bbb42.tar
perl-URPM-28d84b5486cfd87c5e9882d552367408e30bbb42.tar.gz
perl-URPM-28d84b5486cfd87c5e9882d552367408e30bbb42.tar.bz2
perl-URPM-28d84b5486cfd87c5e9882d552367408e30bbb42.tar.xz
perl-URPM-28d84b5486cfd87c5e9882d552367408e30bbb42.zip
fix a segfault when callbacks don't get a header
-rw-r--r--NEWS2
-rw-r--r--URPM.xs8
2 files changed, 8 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index a17f430..65b0641 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+- fix a segfault when callbacks don't get a header
+
Version 5.04 - 26 February 2015
- callbacks now get pkg name instead of just pkg id
diff --git a/URPM.xs b/URPM.xs
index f4ac459..40e3c46 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -1314,8 +1314,12 @@ static void *rpmRunTransactions_callback(const void *arg,
mPUSHs(newSViv(total));
}
// for erasures, the key provided by librpm is always 0, so let's add another parameter (fullname):
- char *s = headerGetAsString(h, RPMTAG_NVR);
- mPUSHs(newSVpv(s, 0));
+ if (h) {
+ char *s = headerGetAsString(h, RPMTAG_NVR);
+ mPUSHs(newSVpv(s, 0));
+ } else {
+ PUSHs(&PL_sv_undef);
+ }
PUTBACK;
i = call_sv(callback, callback == td->callback_open ? G_SCALAR : G_DISCARD);
SPAGAIN;