### 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
*(cursor_image->pixels + index) = image->get_pixel(column_index, row_index).to_argb32();
		}
		ERR_FAIL_COND(cursor_image->pixels == nullptr);
		
		cursors[p_shape] = XcursorImageLoadCursor(x11_display, cursor_image);
		Vector<Variant> params;
		params.push_back(p_cursor);
		params.push_back(p_hotspot);
		cursors_cache.insert(p_shape, params);
		if (p_shape == current_cursor) {
			if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) {
				for (const KeyValue<WindowID, WindowData> &E : windows) {
					XDefineCursor(x11_display, E.value.x11_window, cursors[p_shape]);
				}
			}
		}
		memfree(cursor_image->pixels);
		XcursorImageDestroy(cursor_image);
	} else {
		
		if (cursor_img[p_shape]) {
			cursors[p_shape] = XcursorImageLoadCursor(x11_display, cursor_img[p_shape]);
		}
		cursors_cache.erase(p_shape);
		CursorShape c = current_cursor;
		current_cursor = CURSOR_MAX;
		cursor_set_shape(c);
	}
}
int DisplayServerX11::keyboard_get_layout_count() const {