Skip to content

Commit

Permalink
Properly fix UB after GL_RebuildLighting().
Browse files Browse the repository at this point in the history
Fix without crashing in LM_RebuildSurfaces() this time.
  • Loading branch information
skullernet committed Dec 15, 2023
1 parent b8bc79d commit d7e4d98
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/refresh/surf.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,10 @@ static void LM_UploadBlock(void)

static void build_style_map(int dynamic)
{
static const lightstyle_t fake = { 1 };
int i;

if (!dynamic) {
// make all styles fullbright
glr.fd.lightstyles = (lightstyle_t *)&fake;
memset(gl_static.lightstylemap, 0, sizeof(gl_static.lightstylemap));
return;
}
Expand Down Expand Up @@ -1074,8 +1072,12 @@ void GL_LoadWorld(const char *name)
gl_static.nolm_mask = SURF_NOLM_MASK_REMASTER;
}

glr.fd.lightstyles = &(lightstyle_t){ 1 };

// post process all surfaces
upload_world_surfaces();

glr.fd.lightstyles = NULL;

GL_ShowErrors(__func__);
}

0 comments on commit d7e4d98

Please sign in to comment.