Merge branch 'fix-buffer-overflow-hud-string' into 'next'

Fix segfault when passing a long string to v.drawString

See merge request STJr/SRB2!2403
This commit is contained in:
sphere 2024-06-03 14:25:41 +00:00
commit f67d349b35

View file

@ -180,7 +180,8 @@ static const char *CopyString(huddrawlist_h list, const char* str)
const char *old_offset = list->strbuf;
size_t i;
if (list->strbuf_capacity == 0) list->strbuf_capacity = 256;
else list->strbuf_capacity *= 2;
while (list->strbuf_capacity <= list->strbuf_len + lenstr + 1)
list->strbuf_capacity *= 2;
list->strbuf = (char*) Z_Realloc(list->strbuf, sizeof(char) * list->strbuf_capacity, PU_STATIC, NULL);
// align the string pointers to make sure old pointers don't point towards invalid addresses