shm: Make sure to not allocate blocks larger than the shared mem area

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=681359
This commit is contained in:
Olivier Crête 2013-02-27 20:57:56 -05:00
parent a51b239167
commit 7a77b41d6a

View file

@ -102,13 +102,11 @@ shm_alloc_space_alloc_block (ShmAllocSpace * self, unsigned long size)
prev_item = item; prev_item = item;
} }
/* Did not find space before an existing block */ /* Return NULL if there is no big enough space, otherwise, there is space
if (self->blocks && !item) { * at the end */
/* Return NULL if there is no big enough space, otherwise, there is space assert (prev_end_offset <= self->size);
* at the end */ if (!item && self->size - prev_end_offset < size)
if (self->size - prev_end_offset < size) return NULL;
return NULL;
}
block = spalloc_new (ShmAllocBlock); block = spalloc_new (ShmAllocBlock);
memset (block, 0, sizeof (ShmAllocBlock)); memset (block, 0, sizeof (ShmAllocBlock));