]> granicus.if.org Git - graphviz/commitdiff
gvPluginList: fix unchecked allocation failure
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 26 Jun 2022 20:18:46 +0000 (13:18 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 2 Jul 2022 00:13:06 +0000 (17:13 -0700)
When `strdup` failed to allocate memory, this would go unnoticed, leading to a
crash.

lib/gvc/gvplugin.c

index 741faf91016783ad4615ceefcb767bffc86c76e7..c4ce141ba73709c36f9e54d18dc47fb68f7d5b02 100644 (file)
@@ -30,6 +30,7 @@
 #include        <gvc/gvio.h>
 
 #include       <common/const.h>
+#include <cgraph/alloc.h>
 #include <cgraph/strcasecmp.h>
 #include <cgraph/strview.h>
 
@@ -427,7 +428,7 @@ char **gvPluginList(GVC_t * gvc, const char *kind, int *sz, const char *str)
     strview_t typestr_last = {NULL};
     for (pnext = plugin; pnext; pnext = pnext->next) {
         /* list only one instance of type */
-        q = strdup(pnext->typestr);
+        q = gv_strdup(pnext->typestr);
         if ((p = strchr(q, ':')))
             *p++ = '\0';
         if (!typestr_last.data || strcasecmp(typestr_last.data, q) != 0) {