summaryrefslogtreecommitdiff
path: root/smalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'smalloc.c')
-rw-r--r--smalloc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/smalloc.c b/smalloc.c
index 67cb7cc1..66f9ec0d 100644
--- a/smalloc.c
+++ b/smalloc.c
@@ -492,9 +492,10 @@ void *scalloc(size_t nmemb, size_t size)
char *smalloc_strdup(const char *str)
{
- char *ptr;
+ char *ptr = NULL;
ptr = smalloc(strlen(str) + 1);
- strcpy(ptr, str);
+ if (ptr)
+ strcpy(ptr, str);
return ptr;
}