elm_prefs_cc_parse.c: tok null check in advance.
authorDaniel Juyung Seo <seojuyung2@gmail.com>
Sun, 11 Aug 2013 06:38:16 +0000 (15:38 +0900)
committerDaniel Juyung Seo <seojuyung2@gmail.com>
Sun, 11 Aug 2013 06:38:16 +0000 (15:38 +0900)
This fixes coverity CID 1040003 Dereference before null check (REVERSE_INULL).

src/bin/elm_prefs_cc_parse.c

index 2e44c46ffda9c139eab2026f9d6ecd7fbeadc0f4..8e2bae3df5d4eb9d9368d151ea8bf5dec722275d 100644 (file)
@@ -388,6 +388,7 @@ done:
    *new_p = p;
 
    tok = mem_alloc(tok_end - tok_start + 2);
+   if (!tok) return NULL;
    strncpy(tok, tok_start, tok_end - tok_start + 1);
    tok[tok_end - tok_start + 1] = 0;
 
@@ -425,7 +426,7 @@ done:
                }
           }
      }
-   else if ((tok) && (*tok == '('))
+   else if (*tok == '(')
      {
         char *tmp;
         tmp = tok;