]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Fix a possible divide by zero in Mod_PSKMODEL_Load.
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 9 May 2021 20:21:47 +0000 (20:21 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 9 May 2021 20:21:47 +0000 (20:21 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13133 d7cf8633-e32d-0410-b094-e92efae38249

model_alias.c

index b9990beb6b28e5dd6e9c20082cbc99d567fa3c0a..11ac0d2830e1a0f3d556d1954824c4baaba4f530 100644 (file)
@@ -3073,6 +3073,8 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend)
                        biggestorigin = max(biggestorigin, fabs(k->origin[2]));
                }
                loadmodel->num_posescale = biggestorigin / 32767.0f;
+               if (loadmodel->num_posescale == 0) // don't divide by zero
+                       loadmodel->num_posescale = 1.0;
                loadmodel->num_poseinvscale = 1.0f / loadmodel->num_posescale;
        
                // load the poses from the animkeys
@@ -3112,6 +3114,8 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend)
                        biggestorigin = max(biggestorigin, fabs(p->basepose.origin[2]));
                }
                loadmodel->num_posescale = biggestorigin / 32767.0f;
+               if (loadmodel->num_posescale == 0) // don't divide by zero
+                       loadmodel->num_posescale = 1.0;
                loadmodel->num_poseinvscale = 1.0f / loadmodel->num_posescale;
        
                // load the basepose as a frame