From 5d92ce3a181c439e0b5a160a5820bf20ccaf5414 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Thu, 18 Aug 2011 15:37:13 +0200 Subject: xcb-shm: Fix a logic error while allocating mem The "continue;" in the old code never worked, because it first checked the loop condition. Since "FALSE" (hopefully) never evaluates to true, the loop was still left. Signed-off-by: Uli Schlachter --- src/cairo-xcb-shm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/cairo-xcb-shm.c') diff --git a/src/cairo-xcb-shm.c b/src/cairo-xcb-shm.c index 1d630a7c..ffcaec8f 100644 --- a/src/cairo-xcb-shm.c +++ b/src/cairo-xcb-shm.c @@ -548,11 +548,12 @@ _cairo_xcb_connection_allocate_shm_info (cairo_xcb_connection_t *connection, if (pool->shmid != -1) break; - if (errno == EINVAL && bytes > size) { - bytes >>= 1; - continue; - } - } while (FALSE); + /* If the allocation failed because we asked for too much memory, we try + * again with a smaller request, as long as our allocation still fits. */ + bytes >>= 1; + if (errno != EINVAL || bytes < size) + break; + } while (TRUE); if (pool->shmid == -1) { int err = errno; if (! (err == EINVAL || err == ENOMEM)) -- cgit v1.2.3