From a7395400e7de63712608c121a7916e171170da0a Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Wed, 25 Nov 2015 16:48:11 +0200 Subject: [PATCH] Fix stacktrace [...] handling The compilation error and C call site were not taken into account, which caused the traceback to contain a truncation marker early. --- src/duk_bi_error.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/duk_bi_error.c b/src/duk_bi_error.c index 674e4ab7..d8c93d58 100644 --- a/src/duk_bi_error.c +++ b/src/duk_bi_error.c @@ -119,6 +119,7 @@ DUK_LOCAL duk_ret_t duk__error_getter_helper(duk_context *ctx, duk_small_int_t o duk_idx_t idx_td; duk_small_int_t i; /* traceback depth fits into 16 bits */ duk_small_int_t t; /* stack type fits into 16 bits */ + duk_small_int_t count_func = 0; /* traceback depth ensures fits into 16 bits */ const char *str_tailcalled = " tailcalled"; const char *str_strict = " strict"; const char *str_construct = " construct"; @@ -164,6 +165,8 @@ DUK_LOCAL duk_ret_t duk__error_getter_helper(duk_context *ctx, duk_small_int_t o * Ecmascript/native function call or lightfunc call */ + count_func++; + /* [ ... v1(func) v2(pc+flags) ] */ h_func = duk_get_hobject(ctx, -2); /* NULL for lightfunc */ @@ -262,7 +265,7 @@ DUK_LOCAL duk_ret_t duk__error_getter_helper(duk_context *ctx, duk_small_int_t o } } - if (i >= DUK_USE_TRACEBACK_DEPTH * 2) { + if (count_func >= DUK_USE_TRACEBACK_DEPTH) { /* Possibly truncated; there is no explicit truncation * marker so this is the best we can do. */