Skip to content

Commit

Permalink
Fixed parser segfaulting on bad read (NULL) (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerjenigeUberMensch authored Aug 27, 2024
1 parent 7a903f7 commit 7a70473
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ SCParserSearch(
const char *const NAME
)
{
if(!parser)
if(!parser || !NAME)
{ return NULL;
}
khint_t k = kh_get(__STR__TABLE__, parser->strtable, NAME);
Expand Down Expand Up @@ -553,7 +553,9 @@ SCParserReadFile(
}
memcpy(typename, buff + namelen + 1, typenamelen);
typename[typenamelen - 1] = '\0';
item = SCParserSearch(parser, name);
/* assuming its '=' */
buff[namelen] = '\0';
item = SCParserSearch(parser, buff);
if(!item)
{ item = SCParserSearchSlow(parser, name);
}
Expand Down

0 comments on commit 7a70473

Please sign in to comment.