From 57f32c0b9031c771d20bdb51d5947e4314b1bedc Mon Sep 17 00:00:00 2001 From: calvin2021y <85545400+calvin2021y@users.noreply.github.com> Date: Fri, 6 Sep 2024 19:44:19 +0800 Subject: [PATCH] fix zero size zchunk --- src/zchunk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/zchunk.c b/src/zchunk.c index e53fb258a..c5111d43f 100644 --- a/src/zchunk.c +++ b/src/zchunk.c @@ -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; @@ -181,6 +183,7 @@ zchunk_data (zchunk_t *self) { assert (self); assert (zchunk_is (self)); + if( self->size < 1 ) return NULL; return self->data; }