From fff84559038691f3722dc74c1238b21f5ea6973d Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Wed, 31 Jul 2013 22:03:59 -0400 Subject: [PATCH] Fixed crash in SDKHooks when throwing bad ent type error on logical ent (r=psychonic). --- extensions/sdkhooks/natives.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/extensions/sdkhooks/natives.cpp b/extensions/sdkhooks/natives.cpp index 8b8d25a0..22c171e8 100644 --- a/extensions/sdkhooks/natives.cpp +++ b/extensions/sdkhooks/natives.cpp @@ -57,10 +57,19 @@ cell_t Native_Hook(IPluginContext *pContext, const cell_t *params) pContext->ThrowNativeError("Hook type not supported on this game"); break; case HookRet_BadEntForHookType: - pContext->ThrowNativeError("Hook type not valid for this type of entity (%s)", - PEntityOfEntIndex(gamehelpers->ReferenceToIndex(params[1]))->GetClassName() - ); + { + const char * pClassname = gamehelpers->GetEntityClassname(PEntityOfEntIndex(gamehelpers->ReferenceToIndex(params[1]))); + if (!pClassname) + { + pContext->ThrowNativeError("Hook type not valid for this type of entity (%i).", entity); + } + else + { + pContext->ThrowNativeError("Hook type not valid for this type of entity (%s)", pClassname); + } + break; + } } return 0;