From: thib Date: Sun, 18 Jun 2000 13:14:16 +0000 (+0000) Subject: strdup2 now check the return value of malloc() X-Git-Tag: ver1564~614 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f36df0f88bf3bb73432330199500d4ff92733b2f;p=fcron strdup2 now check the return value of malloc() --- diff --git a/subs.c b/subs.c index a8e7d05..5267e0b 100644 --- a/subs.c +++ b/subs.c @@ -22,10 +22,11 @@ * `LICENSE' that comes with the fcron source distribution. */ - /* $Id: subs.c,v 1.3 2000-05-30 19:27:35 thib Exp $ */ + /* $Id: subs.c,v 1.4 2000-06-18 13:14:16 thib Exp $ */ #include "global.h" +extern void die_e(char *fmt, ...); int remove_blanks(char *str) @@ -61,8 +62,10 @@ strdup2(const char *str) { char *ptr = malloc(strlen(str) + 1); - if (ptr) - strcpy(ptr, str); + if ( ! ptr) + die_e("Could not calloc"); + + strcpy(ptr, str); return(ptr); }