Fix segfault when rpmbuild stumbles over an empty file list.
authorPaul Nasrat <pnasrat@redhat.com>
Mon, 16 Apr 2007 12:14:17 +0000 (13:14 +0100)
committerPaul Nasrat <pnasrat@redhat.com>
Mon, 16 Apr 2007 12:14:17 +0000 (13:14 +0100)
The "+ 1" is a remedy for xmalloc(0), which would return NULL.
Patch from OpenSuSE

build/files.c

index f1d6a19..c38b0d3 100644 (file)
@@ -1392,7 +1392,7 @@ static void genCpioListAndHeader(/*@partial@*/ FileList fl,
        : (int *)(fi->bnl + fi->fc);
 /*@=dependenttrans@*/
 
-    fi->apath = xmalloc(fi->fc * sizeof(*fi->apath) + apathlen);
+    fi->apath = xmalloc(fi->fc * sizeof(*fi->apath) + apathlen + 1);
     a = (char *)(fi->apath + fi->fc);
     *a = '\0';