Don't segfault on a header without RPMTAG_NAME (rhbz#239557).
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 18 Jun 2007 09:48:07 +0000 (12:48 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 18 Jun 2007 09:48:07 +0000 (12:48 +0300)
Patch from JBJ.

lib/formats.c

index 6eebf83..59f953a 100644 (file)
@@ -1028,8 +1028,11 @@ static int i18nTag(Header h, int_32 tag, /*@out@*/ rpmTagType * type,
        {   const char * tn = tagName(tag);
            const char * n;
            char * mk;
-           (void) headerNVR(h, &n, NULL, NULL);
-           mk = alloca(strlen(n) + strlen(tn) + sizeof("()"));
+           size_t nb = sizeof("()");
+           int xx = headerNVR(h, &n, NULL, NULL);
+           if (tn)     nb += strlen(tn);
+           if (n)      nb += strlen(n);
+           mk = alloca(nb);
            sprintf(mk, "%s(%s)", n, tn);
            msgkey = mk;
        }