Don't crash on package without RPMTAG_OS
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 23 May 2008 10:46:21 +0000 (13:46 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 23 May 2008 14:07:35 +0000 (17:07 +0300)
- damn pubkey "packages"

lib/rpmte.c

index e397c74..2212405 100644 (file)
@@ -79,7 +79,7 @@ static void addTE(rpmts ts, rpmte p, Header h,
 {
     int scareMem = 0;
     rpmte savep;
-    const char *name, *version, *release, *arch;
+    const char *name, *version, *release, *arch, *os;
     struct rpmtd_s td;
 
     name = version = release = arch = NULL;
@@ -97,7 +97,8 @@ static void addTE(rpmts ts, rpmte p, Header h,
     p->archScore = arch ? rpmMachineScore(RPM_MACHTABLE_INSTARCH, arch) : 0;
 
     headerGet(h, RPMTAG_OS, &td, HEADERGET_MINMEM);
-    p->os = xstrdup(rpmtdGetString(&td));
+    os = rpmtdGetString(&td);
+    p->os = os ? xstrdup(os) : NULL;
     p->osScore = p->os ? rpmMachineScore(RPM_MACHTABLE_INSTOS, p->os) : 0;
 
     p->isSource = headerIsSource(h);