about summary refs log tree commit diff
path: root/isomac.c
diff options
context:
space:
mode:
Diffstat (limited to 'isomac.c')
-rw-r--r--isomac.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/isomac.c b/isomac.c
index f1d2d7d4a1..47040e61e6 100644
--- a/isomac.c
+++ b/isomac.c
@@ -185,6 +185,7 @@ char *CC;
 /* The -I parameters for CC to find all headers.  */
 char *INC;
 
+static char *xstrndup (const char *, size_t);
 static const char **get_null_defines (void);
 static int check_header (const char *, const char **);
 
@@ -222,6 +223,20 @@ main (int argc, char *argv[])
 }
 
 
+static char *
+xstrndup (const char *s, size_t n)
+{
+  size_t len = n;
+  char *new = malloc (len + 1);
+
+  if (new == NULL)
+    return NULL;
+
+  new[len] = '\0';
+  return memcpy (new, s, len);
+}
+
+
 static const char **
 get_null_defines (void)
 {
@@ -285,7 +300,7 @@ get_null_defines (void)
       start = &line[8];
       for (end = start + 1; !isspace (*end) && *end != '\0'; ++end)
 	;
-      result[result_len++] = strndup (start, end - start);
+      result[result_len++] = xstrndup (start, end - start);
 
       if (first)
 	{