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=aa038fa98c431741be519f95c9434817ab9c0f97;p=rrdtool-all.git handle NULL pointers gracefully git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@222 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_cgi.c b/program/src/rrd_cgi.c index 4543044c..7f248ab0 100644 --- a/program/src/rrd_cgi.c +++ b/program/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); }