From: Ivan Maidanski Date: Mon, 15 Feb 2016 21:32:01 +0000 (+0300) Subject: Fix null-pointer dereferences on out-of-memory in cord/de X-Git-Tag: gc7_6_0~72 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=004e6e47f1d96bd1271306f98b9e21d273262a7b;p=gc Fix null-pointer dereferences on out-of-memory in cord/de * cord/tests/de.c (add_map, add_hist): Check GC_NEW() result for null. --- diff --git a/cord/tests/de.c b/cord/tests/de.c index c42de8e7..da2305e2 100644 --- a/cord/tests/de.c +++ b/cord/tests/de.c @@ -141,6 +141,7 @@ void add_map(int line, size_t pos) { line_map new_map = GC_NEW(struct LineMapRep); + if (NULL == new_map) OUT_OF_MEMORY; if (current_map_size >= MAX_MAP_SIZE) prune_map(); new_map -> line = line; new_map -> pos = pos; @@ -186,6 +187,7 @@ void add_hist(CORD s) { history new_file = GC_NEW(struct HistoryRep); + if (NULL == new_file) OUT_OF_MEMORY; new_file -> file_contents = current = s; current_len = CORD_len(s); new_file -> previous = now;