Bugzilla – Bug 4576
EngFunc_TraceTexture crashes the server!
Last modified: 2014-02-08 23:51:37 PST
It crashes because when it does not find a texture it return NULL pointer and when using the MF_SetAmxString with NULL pointer it crashes the server. So basically this: cRet = MF_GetAmxAddr(amx,params[2]); index = cRet[0]; CHECK_ENTITY(index); cRet = MF_GetAmxAddr(amx,params[3]); Vec1[0]=amx_ctof(cRet[0]); Vec1[1]=amx_ctof(cRet[1]); Vec1[2]=amx_ctof(cRet[2]); cRet = MF_GetAmxAddr(amx,params[4]); Vec2[0]=amx_ctof(cRet[0]); Vec2[1]=amx_ctof(cRet[1]); Vec2[2]=amx_ctof(cRet[2]); temp = (char*)(*g_engfuncs.pfnTraceTexture)(INDEXENT2(index),Vec1,Vec2); cRet = MF_GetAmxAddr(amx,params[6]); MF_SetAmxString(amx, params[5], temp, cRet[0]); return 1; Should turn into this: int index = params[2]; CHECK_ENTITY(index); cell *cRet; float Vec1[3], Vec2[3]; cRet = MF_GetAmxAddr(amx,params[3]); Vec1[0]=amx_ctof(cRet[0]); Vec1[1]=amx_ctof(cRet[1]); Vec1[2]=amx_ctof(cRet[2]); cRet = MF_GetAmxAddr(amx,params[4]); Vec2[0]=amx_ctof(cRet[0]); Vec2[1]=amx_ctof(cRet[1]); Vec2[2]=amx_ctof(cRet[2]); char *temp = (char*)(g_engfuncs.pfnTraceTexture)(INDEXENT2(index), Vec1, Vec2); MF_SetAmxString(amx, params[4], (temp == NULL) ? "NOTEXTURE" : temp, params[5]); return (temp != NULL);
Created attachment 2477 [details] [review] Proposed patch Builds fine, not tested.
Created attachment 2483 [details] [review] Corrected proposed path Previous patch is correct but doesn't follow the current code design and style. This patch corrects that. Compiled and tested successfully in-game. To test, I've used a small plugin. Aim a wall and you should get "NoTexture" instead of a crash. Plugin : http://pastebin.com/3wkKbB29
Pushed changeset: http://hg.alliedmods.net/amxmodx-central/rev/a4cb0f471bcf Changelog: Fix crash in EngFunc_TraceTexture (bug 4576, r=dvander).
Commit pushed to master at https://github.com/alliedmodders/amxmodx https://github.com/alliedmodders/amxmodx/commit/a3aa08637504f0a4aff7f01a2081f4394d5e8b77 Fix crash in EngFunc_TraceTexture (bug 4576, r=dvander). Former-commit-id: c439946a3451dbdfafa2f542e08bc7f83d586165