Re: [MI tracepoints 6/9] trace variable commands

Pedro Alves
2010-03-15T18:00:47Z

On Sunday 14 March 2010 08:58:36, Vladimir Prus wrote:
> + name = argv[0];
> + if (name[0] != '$')
> + error (_("Name of trace variable should start with '$'"));
> + ++name;
> +
> + expr = parse_expression (argv[0]);
> + back_to = make_cleanup (xfree, expr);
> +
> + if (expr->nelts == 3 && expr->elts[0].opcode == OP_INTERNALVAR)
> + {
> + struct internalvar *intvar = expr->elts[1].internalvar;
> + if (intvar)
> + name = internalvar_name (intvar);
> + }
> +
> + if (!name || *name == '\0')
> + error (_("Invalid name of trace variable"));

Waitaminute. Is there a merge error here?

Repeating the snippet:

> + name = argv[0];
> + if (name[0] != '$')
> + error (_("Name of trace variable should start with '$'"));
> + ++name;
> +

I think this whole bit above shouldn't be here.

> + expr = parse_expression (argv[0]);
> + back_to = make_cleanup (xfree, expr);
> +
> + if (expr->nelts == 3 && expr->elts[0].opcode == OP_INTERNALVAR)
> + {
> + struct internalvar *intvar = expr->elts[1].internalvar;
> + if (intvar)
> + name = internalvar_name (intvar); <<<<<<<< (1)
> + }
> +
> + if (!name || *name == '\0')
> + error (_("Invalid name of trace variable"));

Otherwise, it looks like you can get here with an invalid name, if
the expression did parse sucessfully, but (1) wasn't reached at all.

--
Pedro Alves