Ticket #864: valgrind-gui_internal_html.patch

File valgrind-gui_internal_html.patch, 1.2 KB (added by pini, 11 years ago)
  • navit/command.c

    Description: Fix a read error reported by valgrind during the gui_internal
     html command processing.
    Author: Gilles Filippini <pini@debian.org>
    Forwarded: http://trac.navit-project.org/ticket/864
    Last-Update: 2011-05-24
    old new  
    851851void
    852852command_evaluate(struct attr *attr, const char *expr)
    853853{
     854        // Once the eval has started we can't rely anymore on the content of
     855        // expr which may be freed when the calling widget is destroyed by a
     856        // subsequent command call. Hence the g_strdup.
     857        const char *expr_dup;
    854858        struct result res;
    855859        struct context ctx;
    856860        memset(&res, 0, sizeof(res));
    857861        memset(&ctx, 0, sizeof(ctx));
    858862        ctx.attr=attr;
    859863        ctx.error=0;
    860         ctx.expr=expr;
     864        ctx.expr=expr_dup=g_strdup(expr);
    861865        for (;;) {
    862866                eval_comma(&ctx,&res);
    863867                if (ctx.error)
    864                         return;
     868                        break;
    865869                resolve(&ctx, &res, NULL);
    866870                if (ctx.error)
    867                         return;
    868                 if (!get_op(&ctx,0,";",NULL)) return;
     871                        break;
     872                if (!get_op(&ctx,0,";",NULL))
     873                        break;
    869874        }
     875        g_free(expr_dup);
    870876}
    871877
    872878#if 0