Fix symlink handling and small memory leak
authorGlenn L McGrath <bug1@ihug.co.nz>
Thu, 29 Apr 2004 09:24:19 +0000 (09:24 -0000)
committerGlenn L McGrath <bug1@ihug.co.nz>
Thu, 29 Apr 2004 09:24:19 +0000 (09:24 -0000)
archival/libunarchive/get_header_cpio.c

index e8a68f1c3995795867d20dc5f8bde861ba9505f8..f72c376342002c2d3e4fb85962138da09838e362 100644 (file)
@@ -117,6 +117,8 @@ extern char get_header_cpio(archive_handle_t *archive_handle)
                file_header->link_name[file_header->size] = '\0';
                archive_handle->offset += file_header->size;
                file_header->size = 0; /* Stop possible seeks in future */
+       } else {
+               file_header->link_name = NULL;
        }
        if (nlink > 1 && !S_ISDIR(file_header->mode)) {
                if (file_header->size == 0) { /* Put file on a linked list for later */
@@ -151,5 +153,8 @@ extern char get_header_cpio(archive_handle_t *archive_handle)
        }
 
        archive_handle->offset += file_header->size;
+
+       free(file_header->link_name);
+
        return (EXIT_SUCCESS);
 }