From 5a8df80e5d42195699c96c3e79ccd926b4443187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Vep=C5=A1tas?= Date: Tue, 7 May 2024 11:05:09 -0500 Subject: [PATCH] Avoid core dump from some bad pointer math. This is a temporary patch, till I figure out something better. --- link-grammar/tokenize/lookup-exprs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/link-grammar/tokenize/lookup-exprs.c b/link-grammar/tokenize/lookup-exprs.c index ad3fa366e..27b6e4425 100644 --- a/link-grammar/tokenize/lookup-exprs.c +++ b/link-grammar/tokenize/lookup-exprs.c @@ -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++)