From: Thomas Debesse Date: Tue, 14 Jan 2020 05:52:08 +0000 (+0100) Subject: LoadPNGBuffer: use safe_malloc0 to allocate a zeored imate buffer X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a72f2479af933c41253c30b3d4d1760d97230964;p=xonotic%2Fnetradiant.git LoadPNGBuffer: use safe_malloc0 to allocate a zeored imate buffer valgrind reports there may be issues if this is not initialized --- diff --git a/tools/quake3/q3map2/image.c b/tools/quake3/q3map2/image.c index e5f97a40..36658b86 100644 --- a/tools/quake3/q3map2/image.c +++ b/tools/quake3/q3map2/image.c @@ -230,7 +230,8 @@ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, in /* create image pixel buffer */ *width = w; *height = h; - *pixels = safe_malloc( w * h * 4 ); + /* initialize with zeros, this memory area may not be entirely rewritten */ + *pixels = safe_malloc0( w * h * 4 ); /* create row pointers */ rowPointers = safe_malloc( h * sizeof( byte* ) ); @@ -243,7 +244,6 @@ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, in /* clean up */ free( rowPointers ); png_destroy_read_struct( &png, &info, &end ); - }