aboutsummaryrefslogtreecommitdiffstats
path: root/save_backtrace.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-04-13 00:47:00 +0200
committerMattias Andrée <maandree@kth.se>2019-04-13 00:47:00 +0200
commit40c046fb04e8dfaf50c75a291105a8558b9aae11 (patch)
treeb409fde300d048886a8288e0606ec0e98ce0bb6a /save_backtrace.c
parentREADME: LD_PRELOAD (diff)
downloadliberror-backtrace-40c046fb04e8dfaf50c75a291105a8558b9aae11.tar.gz
liberror-backtrace-40c046fb04e8dfaf50c75a291105a8558b9aae11.tar.bz2
liberror-backtrace-40c046fb04e8dfaf50c75a291105a8558b9aae11.tar.xz
Enable prefetching backtace
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'save_backtrace.c')
-rw-r--r--save_backtrace.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/save_backtrace.c b/save_backtrace.c
index e366abf..7214fa4 100644
--- a/save_backtrace.c
+++ b/save_backtrace.c
@@ -53,9 +53,15 @@ liberror_save_backtrace(struct liberror_error *error)
ret = 0;
out:
- if (error->backtrace && !--error->backtrace->refcount)
- free(error->backtrace);
- error->backtrace = backtrace;
+ if (error) {
+ if (error->backtrace && !--error->backtrace->refcount)
+ free(error->backtrace);
+ error->backtrace = backtrace;
+ } else {
+ if (liberror_saved_backtrace && !--liberror_saved_backtrace->refcount)
+ free(liberror_saved_backtrace);
+ liberror_saved_backtrace = backtrace;
+ }
errno = saved_errno;
return ret;
}