From b07557c1c7c962bc88a4bdded19202cc4c27e7bb Mon Sep 17 00:00:00 2001 From: kyren Date: Sun, 18 Feb 2018 06:09:15 -0500 Subject: [PATCH] more hard to trigger bugs that I noticed doing conversion --- src/util.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util.rs b/src/util.rs index 623701f..cd3940a 100644 --- a/src/util.rs +++ b/src/util.rs @@ -314,11 +314,14 @@ where pub unsafe extern "C" fn error_traceback(state: *mut ffi::lua_State) -> c_int { ffi::luaL_checkstack(state, 2, ptr::null()); - if let Some(error) = pop_wrapped_error(state) { + if is_wrapped_error(state, 1) { ffi::luaL_traceback(state, state, ptr::null(), 0); let traceback = CStr::from_ptr(ffi::lua_tostring(state, -1)) .to_string_lossy() .into_owned(); + ffi::lua_pop(state, 1); + + let error = pop_wrapped_error(state).unwrap(); push_wrapped_error( state, Error::CallbackError { @@ -326,7 +329,6 @@ pub unsafe extern "C" fn error_traceback(state: *mut ffi::lua_State) -> c_int { cause: Arc::new(error), }, ); - ffi::lua_remove(state, -2); } else if !is_wrapped_panic(state, 1) { let s = ffi::lua_tostring(state, 1); let s = if s.is_null() {