]> granicus.if.org Git - graphviz/commitdiff
gvplugin_graph: fix unchecked allocation failures
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 26 Jun 2022 20:28:20 +0000 (13:28 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 2 Jul 2022 00:13:06 +0000 (17:13 -0700)
The substring construction in `gvplugin_graph` unfortunately cannot be easily
converted to `strview_t` because it passes pointers to `agxset` which expects a
`'\0'` terminated string. We can at least fix previously unnoticed allocation
failures though.

lib/gvc/gvplugin.c

index c17bd6d76465c53e1d095b6e538e1ae72daf59d8..b0e7e833247a24d90f67420f2f03d832a6b5b2d8 100644 (file)
@@ -515,7 +515,7 @@ Agraph_t *gvplugin_graph(GVC_t * gvc)
             buf2 = bufa + strlen(bufa);
             for (pnext = gvc->apis[api]; pnext; pnext = pnext->next) {
                 if (pnext->package == package) {
-                    t = q = strdup(pnext->typestr);
+                    t = q = gv_strdup(pnext->typestr);
                     if ((p = strchr(q, ':')))
                         *p++ = '\0';
                     /* Now p = renderer, e.g. "gd"
@@ -691,7 +691,7 @@ Agraph_t *gvplugin_graph(GVC_t * gvc)
             buf2 = bufa + strlen(bufa);
             for (pnext = gvc->apis[api]; pnext; pnext = pnext->next) {
                 if (pnext->package == package) {
-                    t = q = strdup(pnext->typestr);
+                    t = q = gv_strdup(pnext->typestr);
                     if ((p = strchr(q, ':')))
                         *p++ = '\0';
                     /* Now p = renderer, e.g. "gd"