Kaynağa Gözat

Zero out the new memory allocated with realloc().

Julian Andres Klode 14 yıl önce
ebeveyn
işleme
61a406f0fc
2 değiştirilmiş dosya ile 3 ekleme ve 0 silme
  1. 2 0
      apt-pkg/contrib/mmap.cc
  2. 1 0
      debian/changelog

+ 2 - 0
apt-pkg/contrib/mmap.cc

@@ -461,6 +461,8 @@ bool DynamicMMap::Grow() {
 			return false;
 
 		Base = realloc(Base, newSize);
+		/* Set new memory to 0 */
+		memset((char*)Base + WorkSpace, 0, newSize - WorkSpace);
 		if (Base == NULL)
 			return false;
 	}

+ 1 - 0
debian/changelog

@@ -4,6 +4,7 @@ apt (0.9.7) UNRELEASED; urgency=low
     - Fix the Fallback option to work correctly, by not calling
       realloc() on a map mapped by mmap(), and by using malloc
       and friends instead of new[].
+    - Zero out the new memory allocated with realloc().
 
  -- Julian Andres Klode <jak@debian.org>  Sat, 16 Jun 2012 14:28:38 +0200