diff --git a/libyara/exception.h b/libyara/exception.h index 1bb17400f1..b73c0845cc 100644 --- a/libyara/exception.h +++ b/libyara/exception.h @@ -221,6 +221,8 @@ static void exception_handler(int sig, siginfo_t * info, void *context) } } +extern YR_TLS int yr_debug_indent; + typedef struct sigaction sa; #define YR_TRYCATCH(_do_, _try_clause_, _catch_clause_) \ @@ -243,6 +245,8 @@ typedef struct sigaction sa; } \ exception_handler_usecount++; \ pthread_mutex_unlock(&exception_handler_mutex); \ + /* Save the current debug indentation level before the jump. */ \ + int yr_debug_indent_before_jump = yr_debug_indent; \ jumpinfo ji; \ ji.memfault_from = 0; \ ji.memfault_to = 0; \ @@ -256,6 +260,9 @@ typedef struct sigaction sa; } \ else \ { \ + /* Restore debug output indentation in case of failure */ \ + yr_debug_indent = yr_debug_indent_before_jump; \ + \ _catch_clause_ \ } \ pthread_mutex_lock(&exception_handler_mutex); \