[glib] Bug 615379 - g_new macros crash if sizeof(struct_type) == 0



commit 00a7c2e635a4fa95257779c271f0eaa5992e2b37
Author: Behdad Esfahbod <behdad behdad org>
Date:   Thu Apr 22 19:48:13 2010 -0400

    Bug 615379 - g_new macros crash if sizeof(struct_type) == 0

 glib/gmem.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glib/gmem.h b/glib/gmem.h
index 2fef766..54f153b 100644
--- a/glib/gmem.h
+++ b/glib/gmem.h
@@ -88,7 +88,7 @@ gpointer g_try_realloc_n  (gpointer	 mem,
 	  if (__s == 1)			\
 	    __p = g_##func (__n);				\
 	  else if (__builtin_constant_p (__n) &&		\
-	           __n <= G_MAXSIZE / __s)			\
+	           (__s == 0 || __n <= G_MAXSIZE / __s))	\
 	    __p = g_##func (__n * __s);				\
 	  else							\
 	    __p = g_##func##_n (__n, __s);			\
@@ -102,7 +102,7 @@ gpointer g_try_realloc_n  (gpointer	 mem,
 	  if (__s == 1)						\
 	    __p = g_##func (__p, __n);				\
 	  else if (__builtin_constant_p (__n) &&		\
-	           __n <= G_MAXSIZE / __s)			\
+	           (__s == 0 || __n <= G_MAXSIZE / __s))	\
 	    __p = g_##func (__p, __n * __s);			\
 	  else							\
 	    __p = g_##func##_n (__p, __n, __s);			\



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]