svn commit: r191180 - head/lib/libarchive

Tim Kientzle kientzle at FreeBSD.org
Fri Apr 17 01:02:58 UTC 2009


Author: kientzle
Date: Fri Apr 17 01:02:56 2009
New Revision: 191180
URL: http://svn.freebsd.org/changeset/base/191180

Log:
  Fix a memory leak:  Release the current list of /set keywords
  even when we exit on an error.

Modified:
  head/lib/libarchive/archive_read_support_format_mtree.c

Modified: head/lib/libarchive/archive_read_support_format_mtree.c
==============================================================================
--- head/lib/libarchive/archive_read_support_format_mtree.c	Fri Apr 17 01:02:12 2009	(r191179)
+++ head/lib/libarchive/archive_read_support_format_mtree.c	Fri Apr 17 01:02:56 2009	(r191180)
@@ -404,10 +404,13 @@ read_mtree(struct archive_read *a, struc
 		len = readline(a, mtree, &p, 256);
 		if (len == 0) {
 			mtree->this_entry = mtree->entries;
+			free_options(global);
 			return (ARCHIVE_OK);
 		}
-		if (len < 0)
+		if (len < 0) {
+			free_options(global);
 			return (len);
+		}
 		/* Leading whitespace is never significant, ignore it. */
 		while (*p == ' ' || *p == '\t') {
 			++p;
@@ -432,13 +435,16 @@ read_mtree(struct archive_read *a, struc
 		} else
 			break;
 
-		if (r != ARCHIVE_OK)
+		if (r != ARCHIVE_OK) {
+			free_options(global);
 			return r;
+		}
 	}
 
 	archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
 	    "Can't parse line %ju", counter);
-	return ARCHIVE_FATAL;
+	free_options(global);
+	return (ARCHIVE_FATAL);
 }
 
 /*


More information about the svn-src-head mailing list