summaryrefslogtreecommitdiff
path: root/src/cairo-xcb-shm.c
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2011-08-18 15:37:13 +0200
committerUli Schlachter <psychon@znc.in>2011-08-18 16:34:44 +0200
commit5d92ce3a181c439e0b5a160a5820bf20ccaf5414 (patch)
treed9790e07a085f864ace70e0e85ae64707638beef /src/cairo-xcb-shm.c
parent73e7391e6e53b894f763f4715590d3be7e7ec243 (diff)
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 <psychon@znc.in>
Diffstat (limited to 'src/cairo-xcb-shm.c')
-rw-r--r--src/cairo-xcb-shm.c11
1 files changed, 6 insertions, 5 deletions
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))