]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
LoadPNGBuffer: use safe_malloc0 to allocate a zeored imate buffer
authorThomas Debesse <dev@illwieckz.net>
Tue, 14 Jan 2020 05:52:08 +0000 (06:52 +0100)
committerThomas Debesse <dev@illwieckz.net>
Thu, 23 Jan 2020 18:21:39 +0000 (19:21 +0100)
valgrind reports there may be issues if this is not initialized

tools/quake3/q3map2/image.c

index e5f97a40c1dbc8d4d71531bbc237926ef033020f..36658b86dead1f5578a8202a636e60325c6e16bb 100644 (file)
@@ -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 );
-
 }