Skip to content

Commit

Permalink
fix zero size zchunk
Browse files Browse the repository at this point in the history
  • Loading branch information
calvin2021y authored Sep 6, 2024
1 parent caf1e2d commit 57f32c0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/zchunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ zchunk_new (const void *data, size_t size)
if (data) {
self->size = size;
memcpy (self->data, data, self->size);
} else {
if( size > 0 ) self->data[0] = 0;
}
}
return self;
Expand Down Expand Up @@ -181,6 +183,7 @@ zchunk_data (zchunk_t *self)
{
assert (self);
assert (zchunk_is (self));
if( self->size < 1 ) return NULL;
return self->data;
}

Expand Down

0 comments on commit 57f32c0

Please sign in to comment.