aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <peroyvind@mandriva.org>2010-11-17 20:54:34 +0000
committerPer Øyvind Karlsen <peroyvind@mandriva.org>2010-11-17 20:54:34 +0000
commitdc4e3c0dd4d8ae9420ff82d5da8b7080a4334f60 (patch)
tree50526935971b98b91a199136c67cd29a8d7e7afc
parented0d2ad3cef21e96e2d1bc33db4d7d8266d81a5b (diff)
downloadperl-URPM-dc4e3c0dd4d8ae9420ff82d5da8b7080a4334f60.tar
perl-URPM-dc4e3c0dd4d8ae9420ff82d5da8b7080a4334f60.tar.gz
perl-URPM-dc4e3c0dd4d8ae9420ff82d5da8b7080a4334f60.tar.bz2
perl-URPM-dc4e3c0dd4d8ae9420ff82d5da8b7080a4334f60.tar.xz
perl-URPM-dc4e3c0dd4d8ae9420ff82d5da8b7080a4334f60.zip
do some checks on headerGet() return values
-rw-r--r--URPM.xs36
1 files changed, 18 insertions, 18 deletions
diff --git a/URPM.xs b/URPM.xs
index cbe9ca4..9565296 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -207,25 +207,25 @@ get_name(Header header, rpmTag tag) {
HE_t val = (HE_t)memset(alloca(sizeof(*val)), 0, sizeof(*val));
val->tag = tag;
- headerGet(header, val, 0);
-
- if (val->t == RPM_STRING_TYPE)
- return val->p.str;
- else if(val->t == RPM_STRING_ARRAY_TYPE || val->t == RPM_I18NSTRING_TYPE)
- return val->p.argv[val->ix];
+ if(headerGet(header, val, 0)) {
+ if (val->t == RPM_STRING_TYPE)
+ return val->p.str;
+ else if(val->t == RPM_STRING_ARRAY_TYPE || val->t == RPM_I18NSTRING_TYPE)
+ return val->p.argv[val->ix];
+ }
return "";
}
static int
get_int(Header header, rpmTag tag) {
HE_t val = (HE_t)memset(alloca(sizeof(*val)), 0, sizeof(*val));
- int ret;
+ int ret = 0;
val->tag = tag;
- headerGet(header, val, 0);
-
- ret = (val->t == RPM_UINT32_TYPE) ? val->p.ui32p[val->ix >= 0 ? val->ix : 0] : 0;
- val->p.ui32p = _free(val->p.ui32p);
+ if(headerGet(header, val, 0)) {
+ ret = (val->t == RPM_UINT32_TYPE) ? val->p.ui32p[val->ix >= 0 ? val->ix : 0] : 0;
+ val->p.ui32p = _free(val->p.ui32p);
+ }
return ret;
}
@@ -1682,12 +1682,14 @@ Pkg_is_platform_compat(pkg)
CODE:
read_config_files(0);
+ RETVAL = 0;
if (pkg->h && headerIsEntry(pkg->h, RPMTAG_PLATFORM)) {
val->tag = RPMTAG_PLATFORM;
- (void) headerGet(pkg->h, val, 0);
- platform = val->p.str;
- RETVAL = rpmPlatformScore(platform, NULL, 0);
- platform = _free(platform);
+ if(headerGet(pkg->h, val, 0)) {
+ platform = val->p.str;
+ RETVAL = rpmPlatformScore(platform, NULL, 0);
+ platform = _free(platform);
+ }
} else if (pkg->info) {
char *arch;
char *eos;
@@ -1697,9 +1699,7 @@ Pkg_is_platform_compat(pkg)
RETVAL = rpmPlatformScore(platform, NULL, 0);
restore_chars();
_free(platform);
- } else {
- RETVAL = 0;
- }
+ }
OUTPUT:
RETVAL