@@ -881,6 +881,15 @@ void EXT_FUNC AnimationAutomove(const edict_t *pEdict, float flTime)
881881void EXT_FUNC GetBonePosition (const edict_t *pEdict, int iBone, float *rgflOrigin, float *rgflAngles)
882882{
883883 pstudiohdr = (studiohdr_t *)Mod_Extradata (g_psv.models [pEdict->v .modelindex ]);
884+
885+ #ifdef REHLDS_FIXES
886+ if (!pstudiohdr)
887+ return ;
888+
889+ if (iBone < 0 || iBone >= pstudiohdr->numbones )
890+ return ; // invalid bone
891+ #endif
892+
884893 g_pSvBlendingAPI->SV_StudioSetupBones (
885894 g_psv.models [pEdict->v .modelindex ],
886895 pEdict->v .frame ,
@@ -906,14 +915,23 @@ void EXT_FUNC GetAttachment(const edict_t *pEdict, int iAttachment, float *rgflO
906915 mstudioattachment_t *pattachment;
907916 vec3_t angles;
908917
909- angles[0 ] = -pEdict->v .angles [0 ];
910- angles[1 ] = pEdict->v .angles [1 ];
911- angles[2 ] = pEdict->v .angles [2 ];
912-
913918 pstudiohdr = (studiohdr_t *)Mod_Extradata (g_psv.models [pEdict->v .modelindex ]);
919+
920+ #ifdef REHLDS_FIXES
921+ if (!pstudiohdr)
922+ return ;
923+
924+ if (iAttachment < 0 || iAttachment >= pstudiohdr->numattachments )
925+ return ; // invalid attachment
926+ #endif
927+
914928 pattachment = (mstudioattachment_t *)((char *)pstudiohdr + pstudiohdr->attachmentindex );
915929 pattachment += iAttachment;
916930
931+ angles[0 ] = -pEdict->v .angles [0 ];
932+ angles[1 ] = pEdict->v .angles [1 ];
933+ angles[2 ] = pEdict->v .angles [2 ];
934+
917935 g_pSvBlendingAPI->SV_StudioSetupBones (
918936 g_psv.models [pEdict->v .modelindex ],
919937 pEdict->v .frame ,
0 commit comments