]> granicus.if.org Git - graphviz/commitdiff
GD plugin: fix unchecked allocation failures
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 8 Nov 2022 02:33:30 +0000 (18:33 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 11 Nov 2022 01:09:34 +0000 (17:09 -0800)
plugin/gd/gvrender_gd.c

index fc2d1394d952bc0b9e3f361c699100e078895255..ae7979e6c6b7294e31889dc43e20956aabced59f 100644 (file)
@@ -17,6 +17,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <fcntl.h>
+#include <cgraph/alloc.h>
 #include <cgraph/unreachable.h>
 #include <gvc/gvplugin_render.h>
 #include <gvc/gvplugin_device.h>
@@ -243,7 +244,7 @@ static void gdgen_missingfont(char *fontreq) {
            p = DEFAULT_FONTPATH;
 #endif
        free(lastmissing);
-       lastmissing = strdup(fontreq);
+       lastmissing = gv_strdup(fontreq);
        n_errors++;
     }
 }
@@ -488,7 +489,7 @@ static void gdgen_polygon(GVJ_t * job, pointf * A, int n, int filled)
 
     if (pen_ok || fill_ok) {
         if (n > 0 && (size_t)n > points_allocated) {
-           points = realloc(points, (size_t)n * sizeof(gdPoint));
+           points = gv_recalloc(points, points_allocated, (size_t)n, sizeof(gdPoint));
            points_allocated = (size_t)n;
        }
         for (i = 0; i < n; i++) {