Skip to content

Commit

Permalink
GetAttachment: Added attachment index bounds check
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Jul 3, 2023
1 parent 0c5ce53 commit 8841ba4
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions rehlds/engine/r_studio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,14 +906,23 @@ void EXT_FUNC GetAttachment(const edict_t *pEdict, int iAttachment, float *rgflO
mstudioattachment_t *pattachment;
vec3_t angles;

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]);

#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];

g_pSvBlendingAPI->SV_StudioSetupBones(
g_psv.models[pEdict->v.modelindex],
pEdict->v.frame,
Expand Down

0 comments on commit 8841ba4

Please sign in to comment.