wayland: Phase 59 — guard SetupEnvironment rcontext NULL deref

scr->rcontext is NULL in the Wayland path (RContextCreate is only
called under dpy).  SetupEnvironment() is reachable via shell command
launch and RelaunchWindow; wrap the WRASTER_COLOR_RESOLUTION putenv
in a scr->rcontext NULL-check to prevent a crash.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Levi Neely 2026-03-28 07:46:06 +01:00
parent b3acfb2366
commit e82bb279ab
1 changed files with 6 additions and 4 deletions

View File

@ -269,10 +269,12 @@ void SetupEnvironment(WScreen * scr)
strcat(tmp, buf);
putenv(tmp);
}
tmp = wmalloc(60);
snprintf(tmp, 60, "WRASTER_COLOR_RESOLUTION%i=%i", scr->screen,
scr->rcontext->attribs->colors_per_channel);
putenv(tmp);
if (scr->rcontext) { /* Wayland: rcontext is NULL (no X11 colormap) */
tmp = wmalloc(60);
snprintf(tmp, 60, "WRASTER_COLOR_RESOLUTION%i=%i", scr->screen,
scr->rcontext->attribs->colors_per_channel);
putenv(tmp);
}
}
typedef struct {