]> granicus.if.org Git - graphviz/commitdiff
remove initial stack buffer usage in htmlEntityUTF8
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 3 Oct 2020 19:11:32 +0000 (12:11 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 10 Oct 2020 17:46:07 +0000 (10:46 -0700)
The agxbuf used in this function is eventually disowned and its backing memory
needs to be heap-allocated to live beyond the duration of the function call. So
there is no advantage to initially allocating it on the stack as it needs to be
subsequently moved to the heap.

lib/common/utils.c

index d891bae87cf6937bbfe0296a46ae8a64cc84d10b..3369677d8be189b757248b2bde963ef5305931e7 100644 (file)
@@ -1473,7 +1473,6 @@ char* htmlEntityUTF8 (char* s, graph_t* g)
     static boolean warned;
     char*  ns;
     agxbuf xb;
-    unsigned char buf[BUFSIZ];
     unsigned char c;
     unsigned int v;
 
@@ -1485,7 +1484,7 @@ char* htmlEntityUTF8 (char* s, graph_t* g)
        warned = 0;
     }
 
-    agxbinit(&xb, BUFSIZ, buf);
+    agxbinit(&xb, 0, NULL);
 
     while ((c = *(unsigned char*)s++)) {
         if (c < 0xC0)