2011-03-09 Michael Snyder * parse.c (parse_field_expression): Clean up memory gracefullly. Index: parse.c =================================================================== RCS file: /cvs/src/src/gdb/parse.c,v retrieving revision 1.108 diff -u -p -r1.108 parse.c --- parse.c 5 Mar 2011 22:02:47 -0000 1.108 +++ parse.c 9 Mar 2011 20:27:08 -0000 @@ -1211,34 +1211,37 @@ parse_field_expression (char *string, ch struct value *val; int subexp; volatile struct gdb_exception except; + struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); TRY_CATCH (except, RETURN_MASK_ERROR) { in_parse_field = 1; exp = parse_exp_in_context (&string, 0, 0, 0, &subexp); + make_cleanup (xfree, exp); } in_parse_field = 0; if (except.reason < 0 || ! exp) return NULL; if (expout_last_struct == -1) { - xfree (exp); + do_cleanups (cleanups); return NULL; } *name = extract_field_op (exp, &subexp); if (!*name) { - xfree (exp); + do_cleanups (cleanups); return NULL; } + make_cleanup (xfree, name); /* This might throw an exception. If so, we want to let it propagate. */ val = evaluate_subexpression_type (exp, subexp); /* (*NAME) is a part of the EXP memory block freed below. */ *name = xstrdup (*name); - xfree (exp); + do_cleanups (cleanups); return value_type (val); }