]> granicus.if.org Git - graphviz/commitdiff
remove the use of an sfio temporary buffer in expr’s qualify
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 8 Aug 2021 22:39:38 +0000 (15:39 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 12 Aug 2021 14:48:36 +0000 (07:48 -0700)
We can simply use regular malloc for this short-lived allocation. Related to
#1998.

lib/expr/exgram.h

index 37af022572880d7b5aee598a67ccdb3969211047..8f3fca17e2828d0b9643918bb5a7093da3325a68 100644 (file)
@@ -545,12 +545,16 @@ static Exid_t*
 qualify(Exref_t* ref, Exid_t* sym)
 {
        Exid_t* x;
-       char*                   s;
 
        while (ref->next)
                ref = ref->next;
-       sfprintf(expr.program->tmp, "%s.%s", ref->symbol->name, sym->name);
-       s = exstash(expr.program->tmp, NULL);
+       size_t len = strlen(ref->symbol->name) + strlen(sym->name) + 2;
+       char *s = malloc(sizeof(char) * len);
+       if (s == NULL) {
+               exnospace();
+               return NULL;
+       }
+       snprintf(s, len, "%s.%s", ref->symbol->name, sym->name);
        if (!(x = dtmatch(expr.program->symbols, s)))
        {
                if ((x = newof(0, Exid_t, 1, strlen(s) - EX_NAMELEN + 1)))
@@ -565,6 +569,7 @@ qualify(Exref_t* ref, Exid_t* sym)
                        x = sym;
                }
        }
+       free(s);
        return x;
 }