SIMDCompressionAndIntersection icon indicating copy to clipboard operation
SIMDCompressionAndIntersection copied to clipboard

Wanted: Exception when provided an insufficient buffer

Open MeitalKr opened this issue 8 years ago • 8 comments

When trying to decode data using uncompress function I receive an Unhandled exception (Access violation).

The size sending to function is too small, and I expected to get NotEnoughStorage exception so the buffer will resize to the right uncompressed size.

MeitalKr avatar Jan 19 '17 13:01 MeitalKr

I have renamed the issue.

lemire avatar Jan 19 '17 16:01 lemire

To be clear, currently, you can avoid this problem during encoding by providing sufficient buffer memory. For example, if you allocate 2x the original memory plus, say, 1024, you will never run out.

During decoding, the current API assumes that you know the size of the uncompressed array.

lemire avatar Jan 19 '17 16:01 lemire

I don't know what is the original size before it was encoded. in this case, what should be the multiplier to allocate size by decoded data size.

MeitalKr avatar Jan 22 '17 05:01 MeitalKr

+1 for how to calculate the decompressed size if you only have compressed size.

oren4323 avatar Jan 26 '17 10:01 oren4323

This issue is marked as "help wanted" and there is nobody working on it as far as I know.

lemire avatar Jan 28 '17 04:01 lemire

I'm wondering if the easiest way would be to put the uncompressed length at the start of the encoded buffer (just as a plain uint32_t).

cs96and avatar Feb 27 '17 12:02 cs96and

@cs96and

I'm wondering if the easiest way would be to put the uncompressed length at the start of the encoded buffer (just as a plain uint32_t).

It generally works this way already. It is not a format problem, it is an API issue.

lemire avatar Feb 27 '17 16:02 lemire

I created a new issue https://github.com/lemire/SIMDCompressionAndIntersection/issues/20

lemire avatar Feb 27 '17 16:02 lemire