diff options
author | Vincent Sanders <vince@kyllikki.org> | 2017-10-15 13:43:35 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2017-10-15 13:51:05 +0100 |
commit | 71d303a1805b454395b9b2ed4d1007699b9d1314 (patch) | |
tree | 99176bb9155b9c49fea2028ed9747dfb5dae65f6 /src/cursor.c | |
parent | 167205c109291aa1957ba64667efa12ce53bba5d (diff) | |
download | libnsfb-71d303a1805b454395b9b2ed4d1007699b9d1314.tar.gz libnsfb-71d303a1805b454395b9b2ed4d1007699b9d1314.tar.bz2 |
fix unchecked heap allocation returns
Alastair Hughes provided a patch in the bug tracker which I based this
implementation upon.
Closes: #2553
Diffstat (limited to 'src/cursor.c')
-rw-r--r-- | src/cursor.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cursor.c b/src/cursor.c index 87633dc..1f107a5 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -99,7 +99,13 @@ bool nsfb_cursor_plot(nsfb_t *nsfb, struct nsfb_cursor_s *cursor) sav_size = cursor->sav_width * cursor->sav_height * sizeof(nsfb_colour_t); if (cursor->sav_size < sav_size) { - cursor->sav = realloc(cursor->sav, sav_size); + nsfb_colour_t *nsav; + + nsav = realloc(cursor->sav, sav_size); + if (nsav == NULL) { + return false; + } + cursor->sav = nsav; cursor->sav_size = sav_size; } |