fix(color): crash if custom mixer Lua script output name is 6 chars long (#6419)
This commit is contained in:
@@ -146,10 +146,8 @@ class ScriptEditWindow : public Page
|
||||
auto lbl = new DynamicText(
|
||||
line, rect_t{},
|
||||
[=]() {
|
||||
char s[16];
|
||||
getSourceString(
|
||||
s, MIXSRC_FIRST_LUA + (idx * MAX_SCRIPT_OUTPUTS) + i);
|
||||
return std::string(s, sizeof(s) - 1);
|
||||
char* s = getSourceString(MIXSRC_FIRST_LUA + (idx * MAX_SCRIPT_OUTPUTS) + i);
|
||||
return std::string(s);
|
||||
});
|
||||
lbl->padLeft(PAD_LARGE);
|
||||
new DynamicNumber<int16_t>(
|
||||
|
||||
@@ -168,12 +168,7 @@ void luaGetInputs(ScriptInputsOutputs & sid)
|
||||
case 0:
|
||||
luaL_checktype(lsScripts, -2, LUA_TNUMBER); // key is number
|
||||
luaL_checktype(lsScripts, -1, LUA_TSTRING); // value is string
|
||||
{ // To preserve the string value, truncate to 6 chars and move it to the main stack
|
||||
char str[7] = {0};
|
||||
strncpy(str, lua_tostring(lsScripts, -1), 6);
|
||||
lua_pushstring(mainState, &str[0]);
|
||||
}
|
||||
lua_pop(lsScripts, 1);
|
||||
lua_xmove(lsScripts, mainState, 1); // To preserve the string value, move it to the main stack
|
||||
lua_pushnil(lsScripts); // Keep the stack balanced
|
||||
lua_insert(mainState, -2); // Keep the coroutine at the top of the main stack
|
||||
si->name = lua_tostring(mainState, -2);
|
||||
|
||||
Reference in New Issue
Block a user