From 55e9b0c9f6eaa8a35d7a2e0578cdebd6032fdd19 Mon Sep 17 00:00:00 2001 From: oetiker Date: Fri, 14 Nov 2003 23:10:51 +0000 Subject: [PATCH] handle NULL pointers gracefully git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@222 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_cgi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rrd_cgi.c b/src/rrd_cgi.c index 4543044..7f248ab 100644 --- a/src/rrd_cgi.c +++ b/src/rrd_cgi.c @@ -83,7 +83,11 @@ static void calfree (void){ /* create freeable version of the string */ char * stralloc(char *str){ - char *nstr = malloc((strlen(str)+1)*sizeof(char)); + char *nstr; + if (str == NULL) { + return NULL; + } + nstr = malloc((strlen(str)+1)*sizeof(char)); strcpy(nstr,str); return(nstr); } -- 2.11.0