سؤال

This is the code being used to inflate:

z_ret = inflate(&oStream, Z_SYNC_FLUSH); 

z_ret returns Z_DATA_ERROR every time except for the first time in incoming stream

هل كانت مفيدة؟

المحلول

As per the zlib webpage:

Z_DATA_ERROR indicates that inflate() detected an error in the zlib compressed data format, which means that either the data is not a zlib stream to begin with, or that the data was corrupted somewhere along the way since it was compressed.

Alternatively, it's possible that the data was compressed with a specific deflate dictionary, which zlib will need in order to inflate. If this is the case, the according to the link I mentioned:

... we have no idea what the dictionary is, so the Z_NEED_DICT indication is converted to a Z_DATA_ERROR.

I've not used zlib much myself, but this hints that you either have corrupt data, or not enough information to be able to decompress.


Edit: Having looked at Salsa's comment, and examining your code more, it's not clear that this is the actual issue. You don't state what value z_ret has when inflate fails.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top