ref: 75bedca7fb08240bc28a6cd6f7f0604231b5a403
parent: d8054e60750f79b7a5b6d8ce73321823ad5de640
author: Simon Howard <fraggle@soulsphere.org>
date: Sat Sep 2 15:02:54 EDT 2017
textscreen: Check return value from realloc(). This fixes a static analysis warning detected in #939. Thanks to @turol for finding this.
--- a/textscreen/txt_fileselect.c
+++ b/textscreen/txt_fileselect.c
@@ -101,7 +101,12 @@
}
else
{
- result = realloc(result, result_len + bytes + 1);
+ char *new_result = realloc(result, result_len + bytes + 1);
+ if (new_result == NULL)
+ {
+ break;
+ }
+ result = new_result;
memcpy(result + result_len, buf, bytes);
result_len += bytes;
result[result_len] = '\0';