### Godot version

2992ffd25523cb8b3e0ef1b873c40115b8940178

### System information

Windows 10

### Issue description

Godot crashes randomly within a few seconds after project start when moving with the mouse.

![win_err](https://github.com/godotengine/godot/assets/52464204/1da28596-d95b-40f3-b32f-12219ec02c5d)

Started after recent merge of https://github.com/godotengine/godot/pull/67791.
I can confirm that reverting the pr fixes the crashes.

### Steps to reproduce

see desc

### Minimal reproduction project

N/A
}
			}
		} else if (image->bits_per_pixel == 24 && image->red_mask == 0x0000ff && image->green_mask == 0x00ff00 && image->blue_mask == 0xff0000) {
			for (int y = 0; y < height; y++) {
				for (int x = 0; x < width; x++) {
					wr[(y * width + x) * 4 + 0] = sr[(y * width + x) * 3 + 2];
					wr[(y * width + x) * 4 + 1] = sr[(y * width + x) * 3 + 1];
					wr[(y * width + x) * 4 + 2] = sr[(y * width + x) * 3 + 0];
					wr[(y * width + x) * 4 + 3] = 255;
				}
			}
		} else if (image->bits_per_pixel == 32 && image->red_mask == 0xff0000 && image->green_mask == 0x00ff00 && image->blue_mask == 0x0000ff) {
			for (int y = 0; y < height; y++) {
				for (int x = 0; x < width; x++) {
					wr[(y * width + x) * 4 + 0] = sr[(y * width + x) * 4 + 2];
					wr[(y * width + x) * 4 + 1] = sr[(y * width + x) * 4 + 1];
					wr[(y * width + x) * 4 + 2] = sr[(y * width + x) * 4 + 0];
					wr[(y * width + x) * 4 + 3] = 255;
				}
			}
		} else {
			XFree(image);
			ERR_FAIL_V_MSG(Ref<Image>(), vformat("XImage with RGB mask %x %x %x and depth %d is not supported.", (uint64_t)image->red_mask, (uint64_t)image->green_mask, (uint64_t)image->blue_mask, (int64_t)image->bits_per_pixel));
		}
		img = Image::create_from_data(width, height, false, Image::FORMAT_RGBA8, img_data);
		XFree(image);
	}
	return img;
}
float DisplayServerX11::screen_get_refresh_rate(int p_screen) const {