]> granicus.if.org Git - fcron/commitdiff
bug fix : strdup2() returns NULL if its argument is NULL (instead of crashing !)
authorthib <thib>
Sat, 11 Jun 2005 22:54:12 +0000 (22:54 +0000)
committerthib <thib>
Sat, 11 Jun 2005 22:54:12 +0000 (22:54 +0000)
subs.c

diff --git a/subs.c b/subs.c
index 223a2c7220cebca4fac8656cfb1904800e2e0559..5f6014339777c27fd969ea7fa571628ce253624d 100644 (file)
--- 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");