Fix potential bug with derefrencing a NULL pointer

This commit is contained in:
Dale Weiler 2012-04-17 16:22:28 -04:00
parent 7501444add
commit 9031c57e39

9
util.c
View file

@ -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, ...) {