From: Matthew Fernandez Date: Wed, 10 Aug 2022 00:39:45 +0000 (-0700) Subject: xdot parsePolyline: squash -Wconversion warning X-Git-Tag: 5.0.1~14^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8be95b6f62bed93f5116e2fde657245008dd9932;p=graphviz xdot parsePolyline: squash -Wconversion warning 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. --- diff --git a/lib/xdot/xdot.c b/lib/xdot/xdot.c index cdc06fb07..0311169be 100644 --- a/lib/xdot/xdot.c +++ b/lib/xdot/xdot.c @@ -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);