aboutsummaryrefslogtreecommitdiff
path: root/libbacktrace/alloc.c
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2015-09-08 16:46:16 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2015-09-08 16:46:16 +0000
commitc478516be7517e20e150150fea4399d60434bfc3 (patch)
treeeae6d20512a5643294e17bfb41e704ab2559be16 /libbacktrace/alloc.c
parent2eab96661b6c08679ffd4a084f59f3935cfcddb9 (diff)
downloadgcc-c478516be7517e20e150150fea4399d60434bfc3.zip
gcc-c478516be7517e20e150150fea4399d60434bfc3.tar.gz
gcc-c478516be7517e20e150150fea4399d60434bfc3.tar.bz2
re PR other/67457 (segfault in libbacktrace)
PR other/67457 * backtrace.c: #include "internal.h". (struct backtrace_data): Add can_alloc field. (unwind): If can_alloc is false, don't try to get file/line information. (backtrace_full): Set can_alloc field in bdata. * alloc.c (backtrace_alloc): Don't call error_callback if it is NULL. * mmap.c (backtrace_alloc): Likewise. * internal.h: Update comments for backtrace_alloc and backtrace_free. From-SVN: r227533
Diffstat (limited to 'libbacktrace/alloc.c')
-rw-r--r--libbacktrace/alloc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libbacktrace/alloc.c b/libbacktrace/alloc.c
index 143ef68..772d3bf 100644
--- a/libbacktrace/alloc.c
+++ b/libbacktrace/alloc.c
@@ -44,7 +44,8 @@ POSSIBILITY OF SUCH DAMAGE. */
backtrace functions may not be safely invoked from a signal
handler. */
-/* Allocate memory like malloc. */
+/* Allocate memory like malloc. If ERROR_CALLBACK is NULL, don't
+ report an error. */
void *
backtrace_alloc (struct backtrace_state *state ATTRIBUTE_UNUSED,
@@ -55,7 +56,10 @@ backtrace_alloc (struct backtrace_state *state ATTRIBUTE_UNUSED,
ret = malloc (size);
if (ret == NULL)
- error_callback (data, "malloc", errno);
+ {
+ if (error_callback)
+ error_callback (data, "malloc", errno);
+ }
return ret;
}