浏览代码

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 6 年之前
父节点
当前提交
f75130af9e
共有 1 个文件被更改,包括 3 次插入0 次删除
  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;
     *ysize = t - b + 1;
 
+    if (!*xsize || !*ysize)
+	return (0);
+
     *pixbuf = (unsigned char *)G_malloc((*xsize) * (*ysize) * 4);	/* G_fatal_error */
 
     if (!*pixbuf)