An error returned by asprintf is a poor excuse for dying.
* unwind.c (asprintf_error_str): New string constant.
(sprint_call_or_error): Replace error_msg_and_die() with
perror_func_msg() and usage of asprintf_error_str for a return value.
(queue_print): Free tmp->output line only if it is not
asprintf_error_str.
static unw_addr_space_t libunwind_as;
static unsigned int mmap_cache_generation;
+static const char asprintf_error_str[] = "???";
+
void
unwind_init(void)
{
else
n = asprintf(&output_line, STACK_ENTRY_BUG_FMT, __func__);
- if (n < 0)
- error_msg_and_die("error in asprintf");
+ if (n < 0) {
+ perror_func_msg("asprintf");
+ output_line = (char *) asprintf_error_str;
+ }
return output_line;
}
tprints(tmp->output_line);
line_ended();
- free(tmp->output_line);
+ if (tmp->output_line != asprintf_error_str)
+ free(tmp->output_line);
+
tmp->output_line = NULL;
tmp->next = NULL;
free(tmp);