Skip to content

Commit 8b5bc3c

Browse files
committed
Print Squirrel callstack on script runtime error before sq_settop
Caused a nullptr dereference when non-native functions are a part of the callstack. Fixes #3159.
1 parent 83ff0ce commit 8b5bc3c

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/squirrel/squirrel_environment.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include <simplesquirrel/class.hpp>
2222
#include <simplesquirrel/vm.hpp>
23-
#include <sqstdaux.h>
2423

2524
#include "squirrel/squirrel_util.hpp"
2625
#include "squirrel/squirrel_virtual_machine.hpp"
@@ -126,20 +125,13 @@ SquirrelEnvironment::run_script(std::istream& in, const std::string& sourcename)
126125
thread.setForeignPtr(this);
127126
thread.setRootTable(m_table);
128127

129-
thread.run(thread.compileSource(in, sourcename.c_str()));
128+
thread.run(thread.compileSource(in, sourcename.c_str()), true);
130129

131130
m_scripts.push_back(std::move(thread));
132131
}
133-
catch (const ssq::Exception& e)
134-
{
135-
if (e.vm)
136-
sqstd_printcallstack(e.vm);
137-
138-
log_warning << e.what() << std::endl;
139-
}
140-
catch (const std::exception& e)
132+
catch (const std::exception& err)
141133
{
142-
log_warning << e.what() << std::endl;
134+
log_warning << err.what() << std::endl;
143135
}
144136
}
145137

0 commit comments

Comments
 (0)