From: divverent Date: Fri, 24 Sep 2010 21:37:43 +0000 (+0000) Subject: Fix a possible crash when an invalid skinframe gets accessed after cl.time steps... X-Git-Tag: xonotic-v0.1.0preview~56^2~127 X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=e63a0114bbd617c020c6217f5e1fe1145b1d2c78 Fix a possible crash when an invalid skinframe gets accessed after cl.time steps backwards (e.g. due to time syncing) right after an entity has been created. Might fix the steel storm crash, but certainly IS a segfault on unstable network connection. Note that a%b can be negative for a<0, b>0 (unlike mathematical 'mod' operation, C '%' is based on rounding towards zero) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10490 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/gl_rmain.c b/gl_rmain.c index 4f3aeade..250324dc 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -10255,12 +10255,12 @@ texture_t *R_GetCurrentTexture(texture_t *t) R_LoadQWSkin(&r_qwskincache[i], cl.scores[i].qw_skin); t->currentskinframe = r_qwskincache[i].skinframe; if (t->currentskinframe == NULL) - t->currentskinframe = t->skinframes[(int)(t->skinframerate * (cl.time - rsurface.ent_shadertime)) % t->numskinframes]; + t->currentskinframe = t->skinframes[(unsigned int)(t->skinframerate * (cl.time - rsurface.ent_shadertime)) % t->numskinframes]; } else if (t->numskinframes >= 2) - t->currentskinframe = t->skinframes[(int)(t->skinframerate * (cl.time - rsurface.ent_shadertime)) % t->numskinframes]; + t->currentskinframe = t->skinframes[(unsigned int)(t->skinframerate * (cl.time - rsurface.ent_shadertime)) % t->numskinframes]; if (t->backgroundnumskinframes >= 2) - t->backgroundcurrentskinframe = t->backgroundskinframes[(int)(t->backgroundskinframerate * (cl.time - rsurface.ent_shadertime)) % t->backgroundnumskinframes]; + t->backgroundcurrentskinframe = t->backgroundskinframes[(unsigned int)(t->backgroundskinframerate * (cl.time - rsurface.ent_shadertime)) % t->backgroundnumskinframes]; t->currentmaterialflags = t->basematerialflags; t->currentalpha = rsurface.colormod[3];