summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/string/strdup.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/string/strdup.c b/src/string/strdup.c
index 2875796c..3cbc1d69 100644
--- a/src/string/strdup.c
+++ b/src/string/strdup.c
@@ -1,8 +1,14 @@
#include <string.h>
+#include <stdlib.h>
char * strdup(const char *s)
{
- return strndup (s, strlen (s));
+ size_t len = strlen(s);
+ char *ret = malloc(len + 1);
+ if (ret) {
+ strcpy(ret, s);
+ }
+ return ret;
}
/*