From aa038fa98c431741be519f95c9434817ab9c0f97 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@222 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_cgi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); } -- 2.30.2