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

gunzippedData returns nil for large NSData #4

Closed
sriramkay opened this issue Jul 27, 2015 · 5 comments
Closed

gunzippedData returns nil for large NSData #4

sriramkay opened this issue Jul 27, 2015 · 5 comments

Comments

@sriramkay
Copy link

I tried using this code to uncompress(gunzip) gzipped NSData in swift. Gunzip works fine when the gzipped NSData is smaller in size (eg. 653 bytes), however fails (returns nil) for larger NSData (eg. 9491 bytes).

Could you please let me know the fix for this?

@oekekezie
Copy link

I'm not sure how helpful this will be but have you tried checking the result of the call to "deflateInit2_" function in the "gzippedData" function?

Perhaps it is returning something other than "Z_OK" and thus returning "nil." For example, maybe you're actually getting an "Insufficient memory available" error: http://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/zlib-deflateinit2.html.

Just from looking at the source code, it's either that or you're not actually loading any data and so "self.length" is 0 in the "gzippedData" function.

@sriramkay
Copy link
Author

Yes. It is not returning the status as "Z_OK", instead "Z_DATA_ERROR" only for larger NSData.
Is there a way, we could identify the data error description?

@1024jp
Copy link
Owner

1024jp commented Aug 2, 2015

Hi, I've just improved the extension:

  • to return just a empty NSData instead of nil when the given NSData instance has zero-length
  • to print error message if compression/decompression is failed

I hope it is some kind helpful to identify your problem.
(And sorry, I couldn't reproduce your matter. Under my environment, even larger file, for example 18 KB, can be compressed/decompressed)

Just printing error message is of course not a good solution. However I have a plan to integrate the throw error handling on Swift 2.0. So, I don't wanna make change at the moment.

@sriramkay
Copy link
Author

Hi,
Thanks for the error message addition. The error message says "Decompression failed: incorrect data check". Does it mean for checksum integrity?

Additional notes:

  1. The input NSData contains the gzipped image data.
  2. Input data starts with 1f8b (magic number of gzip data).
  3. The gzip was done on Android code and we are trying to gunzip in iOS Swift.
  4. Larger data zipped from iOS does not have any problem while gunzip.

Let me know if you have any suggestions on this.

Thanks.

@1024jp
Copy link
Owner

1024jp commented Apr 20, 2024

This issue was closed because it has been inactive for years since the last update.

@1024jp 1024jp closed this as not planned Won't fix, can't repro, duplicate, stale Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants