From ea67ea901c8be1e8bce5ce333bf133c9f84af31c Mon Sep 17 00:00:00 2001 From: Qianqian Fang Date: Thu, 25 Apr 2024 12:32:12 -0400 Subject: [PATCH] [bug] avoid double-base64-encoding when -Z 2 is used, fix #219 --- src/mcx_utils.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mcx_utils.c b/src/mcx_utils.c index 0a1a9e6d..593200ea 100644 --- a/src/mcx_utils.c +++ b/src/mcx_utils.c @@ -4476,7 +4476,12 @@ int mcx_jdataencode(void* vol, int ndim, uint* dims, char* type, int byte, int } /*compress data using zlib*/ - ret = zmat_encode(totalbytes, (uchar*)vol, &compressedbytes, (uchar**)&compressed, zipid, &status); + if (zipid != zmBase64) { + ret = zmat_encode(totalbytes, (uchar*)vol, &compressedbytes, (uchar**)&compressed, zipid, &status); + } else { + compressed = (uchar*)vol; + compressedbytes = totalbytes; + } if (!ret) { if (!cfg->isdumpjson) { @@ -4521,7 +4526,7 @@ int mcx_jdataencode(void* vol, int ndim, uint* dims, char* type, int byte, int } } - if (compressed) { + if (compressed && zipid != zmBase64) { free(compressed); }