Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 68f4e1f

Browse files
mackylegitster
authored andcommitted
ewah_bitmap.c: do not assume size_t and eword_t are the same size
When buffer_grow changes the size of the buffer using realloc, it first computes and saves the rlw pointer's offset into the buffer using (uint8_t *) math before the realloc but then restores it using (eword_t *) math. In order to do this it's necessary to convert the (uint8_t *) offset into an (eword_t *) offset. It was doing this by dividing by the sizeof(size_t). Unfortunately sizeof(size_t) is not same as sizeof(eword_t) on all platforms. This causes illegal memory accesses and other bad things to happen when attempting to use bitmaps on those platforms. Fix this by dividing by the sizeof(eword_t) instead which will always be correct for all platforms. Signed-off-by: Kyle J. McKay <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 69e4b34 commit 68f4e1f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ewah/ewah_bitmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static inline void buffer_grow(struct ewah_bitmap *self, size_t new_size)
4141
self->alloc_size = new_size;
4242
self->buffer = ewah_realloc(self->buffer,
4343
self->alloc_size * sizeof(eword_t));
44-
self->rlw = self->buffer + (rlw_offset / sizeof(size_t));
44+
self->rlw = self->buffer + (rlw_offset / sizeof(eword_t));
4545
}
4646

4747
static inline void buffer_push(struct ewah_bitmap *self, eword_t value)

0 commit comments

Comments
 (0)