Fix the gl skin segfault.

This was caused by an out-by one error when setting up the skin: if cmap
was 0 then the gl_skin struct would be taken from index -1 of the array and
thus cause all sorts of grief.
This commit is contained in:
Bill Currie 2016-01-04 22:04:39 +09:00
parent 6e65de251c
commit 1ea74c6269

View file

@ -231,19 +231,20 @@ gl_Skin_SetupSkin (skin_t *skin, int cmap)
int changed;
glskin_t *s;
skin->texnum = 0;
skin->auxtex = 0;
if (!cmap) {
return;
}
// simplify cmap usage (texture offset/array index)
cmap--;
s = skins + cmap;
changed = (s->tex != skin->texels);
s->tex = skin->texels;
if (!changed) {
skin->texnum = 0;
skin->auxtex = 0;
if (cmap >= 0) {
skin->texnum = skin_textures + cmap;
if (s->fb)
skin->auxtex = skin_fb_textures + cmap;
}
skin->texnum = skin_textures + cmap;
if (s->fb)
skin->auxtex = skin_fb_textures + cmap;
return;
}
if (s->tex)