Bug 1280844 - Fix a null check in parse.c. r?mt.
This patch fixes things so that we don't deref file before checking it.
MozReview-Commit-ID: 6z6wzfVWNYj
--- a/security/nss/coreconf/mkdepend/parse.c
+++ b/security/nss/coreconf/mkdepend/parse.c
@@ -424,19 +424,26 @@ define(char *def, struct inclist *file)
val = "1";
define2(def, val, file);
}
struct symtab **
slookup(char *symbol, struct inclist *file)
{
register int first = 0;
- register int last = file->i_ndefs - 1;
+ register int last;
- if (file) while (last >= first)
+ if (!file)
+ {
+ return NULL;
+ }
+
+ last = file->i_ndefs - 1;
+
+ while (last >= first)
{
/* Fast inline binary search */
register char *s1;
register char *s2;
register int middle = first + (last - first) / 2;
/* Fast inline strchr() */
s1 = symbol;
@@ -456,17 +463,17 @@ slookup(char *symbol, struct inclist *fi
first = middle + 1;
}
/* else ... */
else
{
last = middle - 1;
}
}
- return(NULL);
+ return NULL;
}
static int
merge2defines(struct inclist *file1, struct inclist *file2)
{
int i;
if ((file1==NULL) || (file2==NULL) ||