Skip to content

Commit

Permalink
More detailed error message box for invalid input string string param…
Browse files Browse the repository at this point in the history
…s. (#126)
  • Loading branch information
MiranDMC authored Apr 17, 2024
1 parent c36999c commit 352f25c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cleo_sdk/CLEO_Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,20 @@ namespace CLEO

auto str = CLEO_ReadStringPointerOpcodeParam(thread, buffer, bufferSize); // returns pointer to source data whenever possible

if (str == nullptr) // other error?
if (str == nullptr) // reading string failed
{
SHOW_ERROR("Invalid input argument %s in script %s\nScript suspended.", GetParamInfo().c_str(), ScriptInfoStr(thread).c_str());
auto isVariableInt = IsVariable(_lastParamType) && (_lastParamArrayType == eArrayDataType::ADT_NONE || _lastParamArrayType == eArrayDataType::ADT_INT);
if ((IsImmInteger(_lastParamType) || isVariableInt) && // pointer argument type?
CLEO_GetOpcodeParamsArray()->dwParam <= MinValidAddress)
{
SHOW_ERROR("Invalid '0x%X' pointer of input string argument %s in script %s", CLEO_GetOpcodeParamsArray()->dwParam, GetParamInfo().c_str(), ScriptInfoStr(thread).c_str());
}
else
{
// other error
SHOW_ERROR("Invalid input argument %s in script %s\nScript suspended.", GetParamInfo().c_str(), ScriptInfoStr(thread).c_str());
}

thread->Suspend();
_lastParamType = DT_INVALID; // mark error
return nullptr;
Expand Down

0 comments on commit 352f25c

Please sign in to comment.