about summary refs log tree commit diff
path: root/string/string.h
diff options
context:
space:
mode:
Diffstat (limited to 'string/string.h')
-rw-r--r--string/string.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/string/string.h b/string/string.h
index 3b6c5e969b..7dbcc41c22 100644
--- a/string/string.h
+++ b/string/string.h
@@ -107,8 +107,11 @@ extern char *strndup __P ((__const char *__string, size_t __n));
 #define strndupa(s, n)							      \
 ({									      \
   __const char *__old = (s);						      \
-  size_t __len = strnlen (__old) + 1;					      \
-  memcpy (__builtin_alloca (__len), __old, __len);			      \
+  char *__new;								      \
+  size_t __len = strnlen (__old);					      \
+  __new = memcpy (__builtin_alloca (__len + 1), __old, __len);		      \
+  __new[__len] = '\0';							      \
+  __new;								      \
 })
 #endif