summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2013-02-27 20:57:56 -0500
committerOlivier CrĂȘte <olivier.crete@collabora.com>2013-02-28 13:16:07 -0500
commit2070077413c833dc2f24c03543b1a37b98f0d6e6 (patch)
treedc4aae3d925150d13f15f71c6dc8a401d0887217
parent775fb7f2f322c20cc025ebfb7ace369ffeda56ad (diff)
shm: Make sure to not allocate blocks larger than the shared mem area
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=681359
-rw-r--r--sys/shm/shmalloc.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/sys/shm/shmalloc.c b/sys/shm/shmalloc.c
index 67bae732f..62c2bc751 100644
--- a/sys/shm/shmalloc.c
+++ b/sys/shm/shmalloc.c
@@ -102,13 +102,11 @@ shm_alloc_space_alloc_block (ShmAllocSpace * self, unsigned long size)
prev_item = item;
}
- /* Did not find space before an existing block */
- if (self->blocks && !item) {
- /* Return NULL if there is no big enough space, otherwise, there is space
- * at the end */
- if (self->size - prev_end_offset < size)
- return NULL;
- }
+ /* Return NULL if there is no big enough space, otherwise, there is space
+ * at the end */
+ assert (prev_end_offset <= self->size);
+ if (!item && self->size - prev_end_offset < size)
+ return NULL;
block = spalloc_new (ShmAllocBlock);
memset (block, 0, sizeof (ShmAllocBlock));