ximcp: Address warning found by UBSan when growing an empty tree

imLcPrs.c:681:52: runtime error: applying zero offset to null pointer

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
This commit is contained in:
Jeremy Huddleston Sequoia 2022-12-03 16:26:47 -08:00
parent 7f7bcd7b6f
commit 496d9bfeed
Failed to extract signature

View file

@ -678,7 +678,7 @@ parseline(
b->treesize = newsize;
/* Re-derive top after realloc() to avoid undefined behaviour
(and crashes on architectures that track pointer bounds). */
if (top >= (DTIndex *) old && top < (DTIndex *) &old[oldsize])
if (old && top >= (DTIndex *) old && top < (DTIndex *) &old[oldsize])
top = (DTIndex *) (((char *)new) + (((char *)top)-(char *)old));
}
p = &b->tree[b->treeused];