From: Ingo Bürk Date: Thu, 3 Dec 2015 17:57:02 +0000 (+0100) Subject: Cast unsigned to signed before comparison X-Git-Tag: 4.12~94^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=256007442f41cd9c461e62337d8d37bdf3407903;p=i3%2Fi3 Cast unsigned to signed before comparison The values of a Rect are unsigned, but can contain signed values. Using MAX when the value is negative causes incorrect behavior and makes the result stay negative, which is what we wanted to avoid here in the first place. Fix by properly casting the value for the comparison. fixes #2094 --- diff --git a/src/x.c b/src/x.c index f1f971e9..faa892aa 100644 --- a/src/x.c +++ b/src/x.c @@ -783,8 +783,8 @@ void x_push_node(Con *con) { /* Ensure we have valid dimensions for our surface. */ // TODO This is probably a bug in the condition above as we should never enter this path // for height == 0. Also, we should probably handle width == 0 the same way. - int width = MAX(rect.width, 1); - int height = MAX(rect.height, 1); + int width = MAX((int32_t)rect.width, 1); + int height = MAX((int32_t)rect.height, 1); xcb_create_pixmap_checked(conn, win_depth, con->frame_buffer.id, con->frame.id, width, height); draw_util_surface_init(conn, &(con->frame_buffer), con->frame_buffer.id,