From 4a238bc6110c499409e7b6fe5490826d0fcec283 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Wed, 31 Mar 2021 18:45:24 +0300 Subject: [PATCH] Update sqratUtil.h --- module/Sqrat/sqratUtil.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/module/Sqrat/sqratUtil.h b/module/Sqrat/sqratUtil.h index 23187cb1..4eff1c9b 100644 --- a/module/Sqrat/sqratUtil.h +++ b/module/Sqrat/sqratUtil.h @@ -519,8 +519,16 @@ inline string LastErrorString(HSQUIRRELVM vm) { sq_pop(vm, 1); return string(); } - sq_tostring(vm, -1); - sq_getstringandsize(vm, -1, &sqErr, &size); + if (SQ_SUCCEEDED(sq_tostring(vm, -1))) + { + sq_getstringandsize(vm, -1, &sqErr, &size); + } + else + { + sqErr = _SC("unknown error"); + size = strlen(sqErr); + sq_pushnull(vm); + } sq_pop(vm, 2); return string(sqErr, static_cast< size_t >(size)); }