summaryrefslogtreecommitdiff
path: root/src/plot/generic.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2017-10-15 13:43:35 +0100
committerVincent Sanders <vince@kyllikki.org>2017-10-15 13:51:05 +0100
commit71d303a1805b454395b9b2ed4d1007699b9d1314 (patch)
tree99176bb9155b9c49fea2028ed9747dfb5dae65f6 /src/plot/generic.c
parent167205c109291aa1957ba64667efa12ce53bba5d (diff)
downloadlibnsfb-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/plot/generic.c')
-rw-r--r--src/plot/generic.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/plot/generic.c b/src/plot/generic.c
index 0c3d9e8..a6dd549 100644
--- a/src/plot/generic.c
+++ b/src/plot/generic.c
@@ -799,6 +799,9 @@ path(nsfb_t *nsfb, int pathc, nsfb_plot_pathop_t *pathop, nsfb_plot_pen_t *pen)
/* allocate storage for the vertexes */
curpt = pts = malloc(ptc * sizeof(nsfb_point_t));
+ if (curpt == NULL) {
+ return false;
+ }
for (path_loop = 0; path_loop < pathc; path_loop++) {
switch (pathop[path_loop].operation) {
@@ -906,10 +909,15 @@ bool select_plotters(nsfb_t *nsfb)
return false;
}
- if (nsfb->plotter_fns != NULL)
+ if (nsfb->plotter_fns != NULL) {
free(nsfb->plotter_fns);
+ }
nsfb->plotter_fns = calloc(1, sizeof(nsfb_plotter_fns_t));
+ if (nsfb->plotter_fns == NULL) {
+ return false;
+ }
+
memcpy(nsfb->plotter_fns, table, sizeof(nsfb_plotter_fns_t));
/* set the generics */