fix logic issue

This commit is contained in:
Pelanyo Kamara 2021-11-09 15:38:33 +00:00
parent a81fecb564
commit 80ff5e3e63
No known key found for this signature in database
GPG key ID: 1C8B9C40A2527035
2 changed files with 6 additions and 4 deletions

View file

@ -82,4 +82,4 @@ jobs:
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: coverage name: coverage
path: coverage path: coverage

View file

@ -204,6 +204,9 @@ extern "C"
{ {
const char* executeScript(const char* source) const char* executeScript(const char* source)
{ {
// static string for caching result (prevents dangling ptr on function exit)
static std::string result;
// setup flags // setup flags
for (Luau::FValue<bool>* flag = Luau::FValue<bool>::list; flag; flag = flag->next) for (Luau::FValue<bool>* flag = Luau::FValue<bool>::list; flag; flag = flag->next)
if (strncmp(flag->name, "Luau", 4) == 0) if (strncmp(flag->name, "Luau", 4) == 0)
@ -221,9 +224,8 @@ extern "C"
// run code + collect error // run code + collect error
std::string error = runCode(L, source); std::string error = runCode(L, source);
result = error;
// output error(s)
static std::string result = error;
if (error.length()) if (error.length())
{ {
return result.c_str(); return result.c_str();