changeset 17664:f22ef1f10c3f

xalloc: don't potentially generate invalid code for xmemdup calls * lib/xalloc.h (xmemdup): Do not mark with _GL_ATTRIBUTE_ALLOC, as this function can initialize the newly-allocated storage with new pointers, which means this function is not malloc-like. See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56955
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 20 May 2014 18:14:48 -0700
parents 59df01cdab26
children 6449329e1063
files ChangeLog lib/xalloc.h
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon May 19 13:04:23 2014 +0100
+++ b/ChangeLog	Tue May 20 18:14:48 2014 -0700
@@ -1,3 +1,11 @@
+2014-05-20  Paul Eggert  <eggert@cs.ucla.edu>
+
+	xalloc: don't potentially generate invalid code for xmemdup calls
+	* lib/xalloc.h (xmemdup): Do not mark with _GL_ATTRIBUTE_ALLOC, as
+	this function can initialize the newly-allocated storage with new
+	pointers, which means this function is not malloc-like.  See:
+	https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56955
+
 2014-05-19  Pádraig Brady  <P@draigBrady.com>
 
 	getlogin_r-tests: avoid false failure under sudo/ssh etc.
--- a/lib/xalloc.h	Mon May 19 13:04:23 2014 +0100
+++ b/lib/xalloc.h	Tue May 20 18:14:48 2014 -0700
@@ -64,7 +64,7 @@
       _GL_ATTRIBUTE_ALLOC_SIZE ((2));
 void *x2realloc (void *p, size_t *pn);
 void *xmemdup (void const *p, size_t s)
-      _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((2));
+      _GL_ATTRIBUTE_ALLOC_SIZE ((2));
 char *xstrdup (char const *str)
       _GL_ATTRIBUTE_MALLOC;