Fix null-pointer dereferences in case of out-of-memory in cord
authorIvan Maidanski <ivmai@mail.ru>
Thu, 11 Feb 2016 21:22:44 +0000 (00:22 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 11 Feb 2016 21:22:44 +0000 (00:22 +0300)
commit390be5517ebd2dc233f7eb7f4487ba870ae938d2
treeaab984525eed29ce4bf21718248705e13dad3bf9
parent9c6d1b3060bda68570e4a0c80412ba8df4deaeb2
Fix null-pointer dereferences in case of out-of-memory in cord

* cord/cordprnt.c: Include <stdlib.h> (for abort() declaration).
* cord/cordprnt.c (OUT_OF_MEMORY): New macro.
* cord/tests/de.c (OUT_OF_MEMORY): Likewise.
* cord/cordprnt.c (CORD_vsprintf): Execute OUT_OF_MEMORY if
GC_MALLOC_ATOMIC returns NULL.
* cord/cordxtra.c (CORD_ec_flush_buf): Likewise.
* cord/tests/de.c (replace_line, main): Likewise.
* tests/cordtest.c (test_extras): Declare "u" local variable; do ABORT
if CORD_substr returns NULL (to avoid null pointer dereference in
strcmp).
* cord/tests/de_win.c (plain_chars, control_chars): Return NULL if
GC_MALLOC_ATOMIC returns NULL.
* cord/tests/de_win.c (WndProc): Execute de_error() (with the
appropriate message) if plain_chars() or control_chars() returned
NULL (and do not call the corresponding TextOutA in such a case).
cord/cordprnt.c
cord/cordxtra.c
cord/tests/cordtest.c
cord/tests/de.c
cord/tests/de_win.c