From: Lyndon Nerenberg Date: Thu, 10 Apr 2014 10:07:16 +0000 (-0700) Subject: Clang's static analyzer reports a potential NULL pointer deref. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/d4288570b9513c706907deb882ec6a15e218d0e3?hp=fb374177e49c56f2d119e770206bb721713af83c Clang's static analyzer reports a potential NULL pointer deref. This is a "shouldn't happen" case, so I have added an assert to quell the warning, and catch the failure in the off chance we do get here with last == NULL. --- diff --git a/uip/new.c b/uip/new.c index 8d235b17..83b09664 100644 --- a/uip/new.c +++ b/uip/new.c @@ -406,8 +406,11 @@ doit(char *cur, char *folders, char *sequences[]) /* If we're fnext, we haven't checked the last node yet. If it's the * current folder, return the first node. */ - if (run_mode == FNEXT && strcmp(last->n_name, cur) == 0) { - return first; + if (run_mode == FNEXT) { + assert(last != NULL); + if (strcmp(last->n_name, cur) == 0) { + return first; + } } if (run_mode == NEW) {