fix free after use in mod_storage_load

This commit is contained in:
Isaac0-dev 2024-03-20 23:06:49 +10:00
parent a022b04638
commit bf23836115

View file

@ -112,7 +112,11 @@ C_FIELD const char* mod_storage_load(const char* key) {
mINI::INIStructure ini;
file.read(ini);
return const_cast<char*>(ini["storage"][key].c_str());
// Store string results in a temporary buffer
// this assumes mod_storage_load will only ever be called by Lua
static char value[MAX_KEY_VALUE_LENGTH];
snprintf(value, MAX_KEY_VALUE_LENGTH, "%s", const_cast<char*>(ini["storage"][key].c_str()));
return value;
}
C_FIELD double mod_storage_load_number(const char* key) {