Explorar o código

ogsf: G_malloc allocates 1 byte even if 0 is requested; We don't want that

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@72967 15284696-431f-4ddb-bdfa-cd5b030d7da7
Huidae Cho %!s(int64=6) %!d(string=hai) anos
pai
achega
f75130af9e
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      lib/ogsf/gsd_prim.c

+ 3 - 0
lib/ogsf/gsd_prim.c

@@ -910,6 +910,9 @@ int gsd_getimage(unsigned char **pixbuf, unsigned int *xsize,
     *xsize = r - l + 1;
     *xsize = r - l + 1;
     *ysize = t - b + 1;
     *ysize = t - b + 1;
 
 
+    if (!*xsize || !*ysize)
+	return (0);
+
     *pixbuf = (unsigned char *)G_malloc((*xsize) * (*ysize) * 4);	/* G_fatal_error */
     *pixbuf = (unsigned char *)G_malloc((*xsize) * (*ysize) * 4);	/* G_fatal_error */
 
 
     if (!*pixbuf)
     if (!*pixbuf)