Hi Tom, > Joel> +VEC(ada_exc_info) * > Joel> +ada_exceptions_list (const char *regexp) > Joel> +{ > Joel> + VEC(ada_exc_info) *result = NULL; > Joel> + struct cleanup *old_chain > Joel> + = make_cleanup (VEC_cleanup (ada_exc_info), &result); > Joel> + regex_t *preg = NULL; > Joel> + int prev_len; > Joel> + > Joel> + if (regexp != NULL) > Joel> + { > Joel> + preg = alloca (sizeof (regex_t)); > > I think regex_t is sufficiently small that you might as well declare an > object in the outer scope and avoid alloca. > > Joel> + discard_cleanups (old_chain); > > This leaks anything done by compile_rx_or_error. I think you need to > pass an inner cleanup to do_cleanups. Attached is a new version of the patch. To fix the memory leak, I ended up splitting the function into two, with one doing the regexp compilation (with associated cleanup), and one building the list from the compiled regexp. This allows me to avoid mixing two types of cleanups within the same function (one that is expected to be discarded, and one that is expected to be performed). And this also helps addressing the commend about regex_t, where I now only need to check regexp once before deciding whether to pass ® or NULL... I also took this opportunity to fix "all exceptions whose name" to follow Eli's advice in the GDB manual, using "whose names" (adding an 's' at the end of "name"). For your convenience if it helps checking the changes, I've also attached a diff that only shows the changes applied on top of the last version sent. Tested on x86_64-linux again. No regression. Thank you! -- Joel