diff options
author | Li Jin <dragon-fly@qq.com> | 2023-01-31 18:17:31 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2023-01-31 18:17:31 +0800 |
commit | e3e45fb330e29cc9b203a70b649e61f62697f88d (patch) | |
tree | 114c8e38a133e875e3a2467a69922e7771f513a1 /src/yue.cpp | |
parent | 5fa51d49705e25d284c4adb16edb625d85e0c601 (diff) | |
download | yuescript-e3e45fb330e29cc9b203a70b649e61f62697f88d.tar.gz yuescript-e3e45fb330e29cc9b203a70b649e61f62697f88d.tar.bz2 yuescript-e3e45fb330e29cc9b203a70b649e61f62697f88d.zip |
fix stack overflow issue in yue.to_ast().
Diffstat (limited to 'src/yue.cpp')
-rw-r--r-- | src/yue.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/yue.cpp b/src/yue.cpp index 5679e58..7adde70 100644 --- a/src/yue.cpp +++ b/src/yue.cpp | |||
@@ -270,15 +270,6 @@ int main(int narg, const char** args) { | |||
270 | ; | 270 | ; |
271 | #ifndef YUE_COMPILER_ONLY | 271 | #ifndef YUE_COMPILER_ONLY |
272 | if (narg == 1) { | 272 | if (narg == 1) { |
273 | lua_State* L = luaL_newstate(); | ||
274 | openlibs(L); | ||
275 | DEFER(lua_close(L)); | ||
276 | pushYue(L, "insert_loader"sv); | ||
277 | if (lua_pcall(L, 0, 0, 0) != 0) { | ||
278 | std::cout << lua_tostring(L, -1) << '\n'; | ||
279 | return 1; | ||
280 | } | ||
281 | int count = 0; | ||
282 | linenoise::SetMultiLine(false); | 273 | linenoise::SetMultiLine(false); |
283 | linenoise::SetCompletionCallback([](const char* editBuffer, std::vector<std::string>& completions) { | 274 | linenoise::SetCompletionCallback([](const char* editBuffer, std::vector<std::string>& completions) { |
284 | std::string buf = editBuffer; | 275 | std::string buf = editBuffer; |
@@ -326,6 +317,15 @@ int main(int narg, const char** args) { | |||
326 | break; | 317 | break; |
327 | } | 318 | } |
328 | }); | 319 | }); |
320 | lua_State* L = luaL_newstate(); | ||
321 | openlibs(L); | ||
322 | DEFER(lua_close(L)); | ||
323 | pushYue(L, "insert_loader"sv); | ||
324 | if (lua_pcall(L, 0, 0, 0) != 0) { | ||
325 | std::cout << lua_tostring(L, -1) << '\n'; | ||
326 | return 1; | ||
327 | } | ||
328 | int count = 0; | ||
329 | std::cout << "Yuescript "sv << yue::version << '\n'; | 329 | std::cout << "Yuescript "sv << yue::version << '\n'; |
330 | while (true) { | 330 | while (true) { |
331 | count++; | 331 | count++; |