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_4_4~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=141bb67b6f64d72a67c4d3341480778c2d4ae49d;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 1587980e..ba8235ad 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;