]> diplodocus.org Git - nmh/commitdiff
Clang's static analyzer reports a potential NULL pointer deref.
authorLyndon Nerenberg <lyndon@orthanc.ca>
Thu, 10 Apr 2014 10:07:16 +0000 (03:07 -0700)
committerLyndon Nerenberg <lyndon@orthanc.ca>
Thu, 10 Apr 2014 10:07:16 +0000 (03:07 -0700)
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.

uip/new.c

index 8d235b1..83b0966 100644 (file)
--- 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) {