summaryrefslogtreecommitdiff
path: root/navit/command.c
diff options
context:
space:
mode:
authorwoglinde <woglinde@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-05-26 08:40:18 +0000
committerwoglinde <woglinde@ffa7fe5e-494d-0410-b361-a75ebd5db220>2011-05-26 08:40:18 +0000
commit8f8c69bb16e4045a3fc3a90d1d0879519d0e0e2f (patch)
tree8ae76f705c16193ee52a018e3db04db442ddb9f5 /navit/command.c
parent0dd99d191ca753da2eb506e1aba76e54f538ef18 (diff)
downloadnavit-svn-8f8c69bb16e4045a3fc3a90d1d0879519d0e0e2f.tar.gz
Fix:core:Add a patch to to satisfy "invalid reads" found with valgrind in command.c, patch was provided by pini, closes ticket #864
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@4500 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/command.c')
-rw-r--r--navit/command.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/navit/command.c b/navit/command.c
index 1c957b2d..2d68c574 100644
--- a/navit/command.c
+++ b/navit/command.c
@@ -851,22 +851,29 @@ command_evaluate_to_boolean(struct attr *attr, const char *expr, int *error)
void
command_evaluate(struct attr *attr, const char *expr)
{
+ /* Once the eval has started we can't rely anymore on the content of
+ * expr which may be freed when the calling widget is destroyed by a
+ * subsequent command call. Hence the g_strdup. */
+
+ const char *expr_dup;
struct result res;
struct context ctx;
memset(&res, 0, sizeof(res));
memset(&ctx, 0, sizeof(ctx));
ctx.attr=attr;
ctx.error=0;
- ctx.expr=expr;
+ ctx.expr=expr_dup=g_strdup(expr);
for (;;) {
eval_comma(&ctx,&res);
if (ctx.error)
- return;
+ break;
resolve(&ctx, &res, NULL);
if (ctx.error)
- return;
- if (!get_op(&ctx,0,";",NULL)) return;
+ break;
+ if (!get_op(&ctx,0,";",NULL))
+ break;
}
+ g_free(expr_dup);
}
#if 0