From: Emden R. Gansner Date: Wed, 18 Feb 2015 20:50:55 +0000 (-0500) Subject: Fix bug where string constants are allocated in temp memory during X-Git-Tag: TRAVIS_CI_BUILD_EXPERIMENTAL~118^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d01ad2994cf06a3b16ff2c564927dc5416df1235;p=graphviz Fix bug where string constants are allocated in temp memory during compilation, but temp memory is freed each time an evaluation is done. --- diff --git a/lib/expr/exparse.y b/lib/expr/exparse.y index 306167f80..02d45fea1 100644 --- a/lib/expr/exparse.y +++ b/lib/expr/exparse.y @@ -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);