1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 01:18:00 +00:00

Unix: stop accessing ctrl->fileselect for font selectors.

The setup code for CTRL_FILESELECT and CTRL_FONTSELECT is shared,
which means it's a mistake to test ctrl->fileselect.just_button in it
without first checking which control type we're actually dealing with.

UBsan picks this up by complaining that the just_button field contains
some byte value that's illegal for a boolean. I think it's also the
cause of an intermittent assertion failure reported recently, in which
dlg_fontsel_set finds that uc->entry is NULL when it never ought to
be. If the byte from the wrong union branch happened to be 0 by sheer
bad luck, that could give rise to exactly that failure.
This commit is contained in:
Simon Tatham 2022-10-28 17:49:59 +01:00
parent a7106d8eb2
commit 475c23875e

View File

@ -2143,7 +2143,10 @@ GtkWidget *layout_ctrls(
case CTRL_FONTSELECT: {
GtkWidget *ww;
if (!ctrl->fileselect.just_button) {
bool just_button = (ctrl->type == CTRL_FILESELECT &&
ctrl->fileselect.just_button);
if (!just_button) {
const char *browsebtn =
(ctrl->type == CTRL_FILESELECT ?
"Browse..." : "Change...");