From: oetiker Date: Fri, 14 Nov 2003 23:10:51 +0000 (+0000) Subject: handle NULL pointers gracefully X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=55e9b0c9f6eaa8a35d7a2e0578cdebd6032fdd19;p=rrdtool.git handle NULL pointers gracefully git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@222 a5681a0c-68f1-0310-ab6d-d61299d08faa --- 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); }