From 2433d04fb3d3204cdc041ed7d9e2509ce2684ea7 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 27 Mar 2020 16:46:57 -0400 Subject: Return NULL if input is NULL --- lib/str.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/str.c') diff --git a/lib/str.c b/lib/str.c index 074bdb1..5bf95ec 100644 --- a/lib/str.c +++ b/lib/str.c @@ -705,6 +705,11 @@ char *normalize_space(char *s) { int add_whitespace = 0; char *result = s; char *tmp; + + if (s == NULL) { + return NULL; + } + if ((tmp = calloc(strlen(s) + 1, sizeof(char))) == NULL) { perror("could not allocate memory for temporary string"); return NULL; -- cgit