Save some trouble by grabbing malloced copy of dir indexes
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 19 Dec 2008 15:27:28 +0000 (17:27 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 19 Dec 2008 15:27:28 +0000 (17:27 +0200)
lib/rpmfi.c

index 6661f39..7aabbda 100644 (file)
@@ -767,7 +767,6 @@ Header relocateFileList(const rpmts ts, rpmfi fi,
     char ** baseNames;
     char ** dirNames;
     uint32_t * dirIndexes;
-    uint32_t * newDirIndexes;
     rpm_count_t fileCount, dirCount, numValid = 0;
     rpm_color_t * fColors = NULL;
     rpm_color_t * dColors = NULL;
@@ -941,7 +940,7 @@ assert(p != NULL);
     }
 
     headerGet(h, RPMTAG_BASENAMES, &bnames, fi->scareFlags);
-    headerGet(h, RPMTAG_DIRINDEXES, &dindexes, fi->scareFlags);
+    headerGet(h, RPMTAG_DIRINDEXES, &dindexes, HEADERGET_ALLOC);
     headerGet(h, RPMTAG_DIRNAMES, &dnames, fi->scareFlags);
     headerGet(h, RPMTAG_FILECOLORS, &fcolors, fi->scareFlags);
     headerGet(h, RPMTAG_FILEMODES, &fmodes, fi->scareFlags);
@@ -958,10 +957,6 @@ assert(p != NULL);
 
     dColors = xcalloc(dirCount, sizeof(*dColors));
 
-    newDirIndexes = xmalloc(sizeof(*newDirIndexes) * fileCount);
-    memcpy(newDirIndexes, dirIndexes, sizeof(*newDirIndexes) * fileCount);
-    dirIndexes = newDirIndexes;
-
     /*
      * For all relocations, we go through sorted file/relocation lists 
      * backwards so that /usr/local relocations take precedence over /usr 
@@ -1188,7 +1183,6 @@ dColors[j] |= fColors[i];
        free(relocations[i].newPath);
     }
     free(relocations);
-    free(newDirIndexes);
     free(dColors);
 
     return h;