]> granicus.if.org Git - graphviz/commitdiff
Fix bug where string constants are allocated in temp memory during
authorEmden R. Gansner <erg@alum.mit.edu>
Wed, 18 Feb 2015 20:50:55 +0000 (15:50 -0500)
committerEmden R. Gansner <erg@alum.mit.edu>
Wed, 18 Feb 2015 20:50:55 +0000 (15:50 -0500)
compilation, but temp memory is freed each time an evaluation is done.

lib/expr/exparse.y

index 306167f80a7e801352724eaf5c03553d8a6a5c41..02d45fea180da9f898eb2d082c48177d063c9b24 100644 (file)
@@ -641,6 +641,14 @@ expr               :       '(' expr ')'
                        if (!expr.program->errors && $1->op == CONSTANT && $3->op == CONSTANT)
                        {
                                $$->data.constant.value = exeval(expr.program, $$, NiL);
+                               /* If a constant string, re-allocate from program heap. This is because the
+                                * value was constructed from string operators, which create a value in the 
+                                * temporary heap, which is cleared when exeval is called again. 
+                                */
+                               if ($$->type == STRING) {
+                                       $$->data.constant.value.string =
+                                               vmstrdup(expr.program->vm, $$->data.constant.value.string);
+                               }
                                $$->binary = 0;
                                $$->op = CONSTANT;
                                exfreenode(expr.program, $1);