File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ enum SDKPassMethod
4545 SDKPass_ByRef, /* *< Pass an object by reference */
4646};
4747
48+ // memory addresses below 0x10000 are automatically considered invalid for dereferencing
49+ #define VALID_MINIMUM_MEMORY_ADDRESS 0x10000
50+
4851int s_vtbl_index = -1 ;
4952void *s_call_addr = NULL ;
5053ValveCallType s_vcalltype = ValveCall_Static;
@@ -365,6 +368,17 @@ static cell_t SDKCall(IPluginContext *pContext, const cell_t *params)
365368 pContext->LocalToPhysAddr (params[startparam], &cell);
366369 void *thisptr = reinterpret_cast <void *>(*cell);
367370
371+ if (thisptr == nullptr )
372+ {
373+ vc->stk_put (ptr);
374+ return pContext->ThrowNativeError (" ThisPtr address cannot be null" );
375+ }
376+ else if (reinterpret_cast <uintptr_t >(thisptr) < VALID_MINIMUM_MEMORY_ADDRESS)
377+ {
378+ vc->stk_put (ptr);
379+ return pContext->ThrowNativeError (" Invalid ThisPtr address 0x%x is pointing to reserved memory." , thisptr);
380+ }
381+
368382 *(void **)ptr = thisptr;
369383 startparam++;
370384 }
You can’t perform that action at this time.
0 commit comments