diff --git a/numcodecs/vlen.pyx b/numcodecs/vlen.pyx index e1e149ee..cf01a4fb 100644 --- a/numcodecs/vlen.pyx +++ b/numcodecs/vlen.pyx @@ -250,9 +250,10 @@ class VLenBytes(Codec): l = lengths[i] store_le32(data, l) data += 4 - encv = PyBytes_AS_STRING(values[i]) - memcpy(data, encv, l) - data += l + if l > 0: + encv = PyBytes_AS_STRING(values[i]) + memcpy(data, encv, l) + data += l return out