commit c4e7edecb3e89dc85d0be4dcbac98834ef5809a8
Author: Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Fri Apr 15 16:38:44 2022 -0600
Commit: Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Fri Apr 15 16:38:44 2022 -0600
Fix passing param to load with nil breadcrumb
---
source/picoluaapi.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/source/picoluaapi.cpp b/source/picoluaapi.cpp
index eaadbb3..0fdf57e 100644
--- a/source/picoluaapi.cpp
+++ b/source/picoluaapi.cpp
@@ -1235,12 +1235,13 @@ int load(lua_State *L) {
const char* filename = "";
const char* breadcrumb = "";
const char* param = "";
- if (lua_isstring(L, 1)){
+ int argC = lua_gettop(L);
+ if (argC > 0 && lua_isstring(L, 1)){
filename = lua_tolstring(L, 1, nullptr);
- if (lua_gettop(L) > 1 && lua_isstring(L, 2)){
+ if (argC > 1 && lua_isstring(L, 2)){
breadcrumb = lua_tolstring(L, 2, nullptr);
}
- if (lua_gettop(L) > 2 && lua_isstring(L, 2)){
+ if (argC > 2 && lua_isstring(L, 3)){
param = lua_tolstring(L, 3, nullptr);
}