]> granicus.if.org Git - graphviz/commitdiff
xdot parsePolyline: squash -Wconversion warning
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 10 Aug 2022 00:39:45 +0000 (17:39 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 10 Aug 2022 15:47:29 +0000 (08:47 -0700)
This code parses an int, but then uses it to allocate an array, so clearly
should take the error path when the parsed int is negative.

lib/xdot/xdot.c

index cdc06fb072e64ef28677dca7ad1a9d2c0c8b39d5..0311169be02be4ccc9704c6f2eab7a77c8e553be 100644 (file)
@@ -92,7 +92,8 @@ static char *parsePolyline(char *s, xdot_polyline * pp)
 
     s = parseInt(s, &i);
     if (!s) return s;
-    pts = ps = gv_calloc(i, sizeof(ps[0]));
+    if (i < 0) return NULL;
+    pts = ps = gv_calloc((size_t)i, sizeof(ps[0]));
     pp->cnt = i;
     for (i = 0; i < pp->cnt; i++) {
        ps->x = strtod (s, &endp);