]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Properly set a error message when memory allocation fails in the RAR reader.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 3 Aug 2011 05:56:22 +0000 (01:56 -0400)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 3 Aug 2011 05:56:22 +0000 (01:56 -0400)
SVN-Revision: 3523

libarchive/archive_read_support_format_rar.c

index 5e7712d9c2dbdafe3539199c7bb920401d9510fb..ec979199a700f56146c082e2fc0bea2dddc8badc 100644 (file)
@@ -671,8 +671,11 @@ read_header(struct archive_read *a, struct archive_entry *entry,
     header_size += rar->packed_size;
 
   filename_size = archive_le16dec(file_header.name_size);
-  if ((filename = malloc(filename_size+1)) == NULL)
+  if ((filename = malloc(filename_size+1)) == NULL) {
+    archive_set_error(&a->archive, ENOMEM,
+                      "Couldn't allocate memory.");
     return (ARCHIVE_FATAL);
+  }
   memcpy(filename, p, filename_size);
   filename[filename_size] = '\0';
   if (rar->file_flags & FHD_UNICODE)