Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wanted: Exception when provided an insufficient buffer #19

Open
MeitalKr opened this issue Jan 19, 2017 · 8 comments
Open

Wanted: Exception when provided an insufficient buffer #19

MeitalKr opened this issue Jan 19, 2017 · 8 comments

Comments

@MeitalKr
Copy link

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.

@lemire lemire changed the title Unhandled exception Wanted: automatic memory allocation Jan 19, 2017
@lemire lemire changed the title Wanted: automatic memory allocation Wanted: Exception when provided an insufficient buffer Jan 19, 2017
@lemire
Copy link
Member

lemire commented Jan 19, 2017

I have renamed the issue.

@lemire
Copy link
Member

lemire commented Jan 19, 2017

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.

@MeitalKr
Copy link
Author

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.

@oren4323
Copy link

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

@lemire
Copy link
Member

lemire commented Jan 28, 2017

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

@cs96and
Copy link

cs96and commented Feb 27, 2017

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).

@lemire
Copy link
Member

lemire commented Feb 27, 2017

@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
Copy link
Member

lemire commented Feb 27, 2017

I created a new issue #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants