2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-28 07:35:47 +03:00

GetAttachment: Added attachment index bounds check

This commit is contained in:
s1lentq 2023-07-04 01:33:41 +07:00
parent 0c5ce53666
commit 8841ba4aec

View File

@ -906,14 +906,23 @@ void EXT_FUNC GetAttachment(const edict_t *pEdict, int iAttachment, float *rgflO
mstudioattachment_t *pattachment;
vec3_t angles;
pstudiohdr = (studiohdr_t *)Mod_Extradata(g_psv.models[pEdict->v.modelindex]);
#ifdef REHLDS_FIXES
if (!pstudiohdr)
return;
if (iAttachment < 0 || iAttachment >= pstudiohdr->numattachments)
return; // invalid attachment
#endif
pattachment = (mstudioattachment_t *)((char *)pstudiohdr + pstudiohdr->attachmentindex);
pattachment += iAttachment;
angles[0] = -pEdict->v.angles[0];
angles[1] = pEdict->v.angles[1];
angles[2] = pEdict->v.angles[2];
pstudiohdr = (studiohdr_t *)Mod_Extradata(g_psv.models[pEdict->v.modelindex]);
pattachment = (mstudioattachment_t *)((char *)pstudiohdr + pstudiohdr->attachmentindex);
pattachment += iAttachment;
g_pSvBlendingAPI->SV_StudioSetupBones(
g_psv.models[pEdict->v.modelindex],
pEdict->v.frame,