Browse Source

dpkg: Switch from non-freeing malloc to m_malloc on statdb slurping

The individual strings are now nfstrsave()ed so there is no need to
allocate the whole file in the non-freeing memory pool.
Guillem Jover 9 years ago
parent
commit
977b99e516
2 changed files with 4 additions and 1 deletions
  1. 1 0
      debian/changelog
  2. 3 1
      src/statdb.c

+ 1 - 0
debian/changelog

@@ -17,6 +17,7 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
     timestamp from SOURCE_DATE_EPOCH.
   * Generate reproducible file modes for the .deb control member contents.
     Closes: #787980
+  * Switch from non-freeing malloc to m_malloc on statdb slurping.
   * Perl modules:
     - Obsolete Source-Version substvar in Dpkg::Substvars by emitting errors.
     - Rework keyring hooks in Dpkg::Vendor. Deprecate the keyrings hook, and

+ 3 - 1
src/statdb.c

@@ -177,7 +177,7 @@ ensure_statoverrides(enum statdb_parse_flags flags)
 		return;
 	}
 
-	loaded_list = nfmalloc(sb_next.st_size);
+	loaded_list = m_malloc(sb_next.st_size);
 	loaded_list_end = loaded_list + sb_next.st_size;
 
 	if (fd_read(fileno(file), loaded_list, sb_next.st_size) < 0)
@@ -261,5 +261,7 @@ ensure_statoverrides(enum statdb_parse_flags flags)
 		thisline = nextline;
 	}
 
+	free(loaded_list);
+
 	onerr_abort--;
 }