Skip to content

Commit 5e7910a

Browse files
committed
update(constructors): Safety checks
1 parent 764565e commit 5e7910a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/plugins/core/scripting/chandle.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ PluginCHandle::PluginCHandle(void* ptr)
77

88
PluginCHandle::PluginCHandle(std::string ptr)
99
{
10+
if (!starts_with(ptr, "0x")) return;
11+
1012
m_Handle = (CHandle<CEntityInstance>*)strtol(ptr.c_str(), nullptr, 16);
1113
}
1214

1315
std::string PluginCHandle::GetPtr()
1416
{
15-
return string_format("%p", (void*)m_Handle->Get());
17+
return string_format("%p", (void*)m_Handle->Get());
1618
}
1719

1820
void PluginCHandle::SetPtr(std::string ptr)
1921
{
22+
if (!starts_with(ptr, "0x")) return;
23+
2024
m_Handle->Set((CEntityInstance*)strtol(ptr.c_str(), nullptr, 16));
2125
}
2226

src/plugins/core/scripting/memory.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ void PluginMemory::LoadFromPtr(void* ptr)
1616
}
1717
void PluginMemory::LoadFromAddress(std::string addr)
1818
{
19+
if (!starts_with(addr, "0x")) return;
20+
1921
m_ptr = (void*)(strtol(addr.c_str(), nullptr, 16));
2022
}
2123

0 commit comments

Comments
 (0)