Skip to content

Commit

Permalink
Merge pull request #1522 from linas/null-pointer-crash
Browse files Browse the repository at this point in the history
Avoid core dump from some bad pointer math.
  • Loading branch information
linas authored May 7, 2024
2 parents 65afe01 + 5a8df80 commit ffb21ec
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions link-grammar/tokenize/lookup-exprs.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

static Dict_node *dictionary_all_categories(Dictionary dict)
{
// Avoid bad pointer math below.
assert(0 != dict->num_categories, "No categories in dict!");

Dict_node * dn = malloc(sizeof(*dn) * dict->num_categories);

for (size_t i = 0; i < dict->num_categories; i++)
Expand Down

0 comments on commit ffb21ec

Please sign in to comment.