@@ -153,7 +153,8 @@ UInt32 CompressionCodecSZ3::doCompressData(const char * source, UInt32 source_si
153153 size_t compressed_size;
154154 switch (float_width)
155155 {
156- case 4 : {
156+ case 4 :
157+ {
157158 try
158159 {
159160 compressed.reset (SZ_compress (config, reinterpret_cast <const float *>(source), compressed_size));
@@ -164,7 +165,8 @@ UInt32 CompressionCodecSZ3::doCompressData(const char * source, UInt32 source_si
164165 }
165166 break ;
166167 }
167- case 8 : {
168+ case 8 :
169+ {
168170 try
169171 {
170172 compressed.reset (SZ_compress (config, reinterpret_cast <const double *>(source), compressed_size));
@@ -196,8 +198,10 @@ void CompressionCodecSZ3::setAndCheckVectorDimension(size_t dimension_)
196198
197199void CompressionCodecSZ3::doDecompressData (const char * source, UInt32 source_size, char * dest, UInt32 /* uncompressed_size*/ ) const
198200{
199- if (source_size == 0 )
200- throw Exception (ErrorCodes::CORRUPTED_DATA, " Can not decompress empty data" );
201+ // / Hardcoded, because it is not declared (we just calculated the minimal size of decompressed config) and it is less than sizeof(SZ3::Config).
202+ static constexpr const size_t config_size = 39 ;
203+ if (source_size < 1 + config_size)
204+ throw Exception (ErrorCodes::CORRUPTED_DATA, " Can not decompress data {} that is less than minimal size of compressed" , source_size);
201205
202206 UInt8 width = static_cast <UInt8>(*source);
203207 --source_size;
@@ -206,7 +210,8 @@ void CompressionCodecSZ3::doDecompressData(const char * source, UInt32 source_si
206210 SZ3::Config config;
207211 switch (width)
208212 {
209- case 4 : {
213+ case 4 :
214+ {
210215 try
211216 {
212217 float * dest_typed = reinterpret_cast <float *>(dest);
@@ -218,7 +223,8 @@ void CompressionCodecSZ3::doDecompressData(const char * source, UInt32 source_si
218223 }
219224 break ;
220225 }
221- case 8 : {
226+ case 8 :
227+ {
222228 try
223229 {
224230 double * dest_typed = reinterpret_cast <double *>(dest);
0 commit comments