Skip to content

Commit

Permalink
Segfault bug fix
Browse files Browse the repository at this point in the history
I forgot that the jump-marker in case a chunk is exhausted still needs to fit in the chunk!
  • Loading branch information
aeplay committed Jan 19, 2017
1 parent efd50e2 commit 37299fc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/chunked/src/lib.rs
Expand Up @@ -406,7 +406,8 @@ impl ChunkedQueue {
let total_size = size + mem::size_of::<usize>();
let offset = *self.write_offset % self.chunker.chunk_size();
let ptr = self.chunks.last_mut().unwrap().offset(offset as isize);
if *self.write_offset + total_size < *self.end_offset {
// one more size marker needs to fit, even if it will just be a jump marker!
if *self.write_offset + total_size + mem::size_of::<usize>() < *self.end_offset {
// store the item size as a header
*(ptr as *mut usize) = total_size;
let payload_ptr = ptr.offset(mem::size_of::<usize>() as isize);
Expand Down

0 comments on commit 37299fc

Please sign in to comment.