From: Dale Weiler Date: Tue, 17 Apr 2012 20:22:28 +0000 (-0400) Subject: Fix potential bug with derefrencing a NULL pointer X-Git-Tag: 0.1-rc1~653 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9031c57e395b03f3b89c0812413a243f0968a816;p=xonotic%2Fgmqcc.git Fix potential bug with derefrencing a NULL pointer --- diff --git a/util.c b/util.c index 6e044ac..44b1108 100644 --- a/util.c +++ b/util.c @@ -106,13 +106,14 @@ char *util_strrq(char *s) { * done pointer wise instead of strlen(), and an array * access. */ -char *util_strrnl(char *s) { - char *cpy = s; - while (cpy && *cpy && *cpy != '\n') +char *util_strrnl(char *src) { + if (!src) return NULL; + char *cpy = src; + while (*cpy && *cpy != '\n') cpy++; *cpy = '\0'; - return s; + return src; } void util_debug(const char *area, const char *ms, ...) {