Skip to content

Commit

Permalink
Fix OOM with obviously corrupt miptex lumps (eg: jvoxdm1.bsp).
Browse files Browse the repository at this point in the history
  • Loading branch information
Shpoike committed Apr 17, 2023
1 parent 5272331 commit 5ed4012
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions engine/gl/gl_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -3737,6 +3737,12 @@ TRACE(("dbg: Mod_LoadTextures: inittexturedescs\n"));

m->nummiptex = LittleLong (m->nummiptex);

if ((1+m->nummiptex)*sizeof(int) > l->filelen)
{
Con_Printf(CON_WARNING "warning: %s contains corrupt texture lump\n", loadmodel->name);
return false;
}

loadmodel->numtextures = m->nummiptex;
loadmodel->textures = ZG_Malloc(&loadmodel->memgroup, m->nummiptex * sizeof(*loadmodel->textures));
sizes = alloca(sizeof(*sizes)*m->nummiptex);
Expand Down

0 comments on commit 5ed4012

Please sign in to comment.