From 2cf7ca8789c095415a387c19f867f3ecb3d597b0 Mon Sep 17 00:00:00 2001 From: thib Date: Sat, 11 Jun 2005 22:54:12 +0000 Subject: [PATCH] bug fix : strdup2() returns NULL if its argument is NULL (instead of crashing !) --- subs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/subs.c b/subs.c index 223a2c7..5f60143 100644 --- a/subs.c +++ b/subs.c @@ -22,7 +22,7 @@ * `LICENSE' that comes with the fcron source distribution. */ - /* $Id: subs.c,v 1.22 2004-11-13 19:43:36 thib Exp $ */ + /* $Id: subs.c,v 1.23 2005-06-11 22:54:12 thib Exp $ */ #include "global.h" #include "subs.h" @@ -74,8 +74,13 @@ remove_blanks(char *str) char * strdup2(const char *str) { - char *ptr = malloc(strlen(str) + 1); + char *ptr; + + if ( str == NULL ) + return NULL; + ptr = malloc(strlen(str) + 1); + if ( ! ptr) die_e("Could not calloc"); -- 2.40.0