]> granicus.if.org Git - graphviz/commitdiff
gxl2gv gxl_to_gv: match XML_Parse, squashing a -Wconversion warning
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 17 Sep 2021 04:32:37 +0000 (21:32 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 19 Sep 2021 23:21:06 +0000 (16:21 -0700)
cmd/tools/gxl2gv.c

index 758cd660fc152b061e39e142062edad31050856a..9adae44d6aea09f38074b7288d5bb1d7e57ba70f 100644 (file)
@@ -14,6 +14,7 @@
 #ifdef HAVE_EXPAT
 #include    <expat.h>
 #include    <ctype.h>
+#include    <limits.h>
 #include    <stdbool.h>
 #include    <stdlib.h>
 
@@ -726,7 +727,8 @@ Agraph_t *gxl_to_gv(FILE * gxlFile)
        if (len == 0)
            break;
        done = len < sizeof(buf);
-       if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) {
+       assert(len <= (size_t)INT_MAX && "too large data for Expat API");
+       if (XML_Parse(parser, buf, (int)len, done) == XML_STATUS_ERROR) {
            fprintf(stderr,
                    "%s at line %lu\n",
                    XML_ErrorString(XML_GetErrorCode(parser)),