# define AT_LEAST_ZLIB_1_2_2_1
#endif
+#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1222
+# define AT_LEAST_ZLIB_1_2_2_2
+#endif
+
#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1223
# define AT_LEAST_ZLIB_1_2_2_3
#endif
s = NULL ;
}
else if (SvCUR(dictionary)) {
+#ifdef AT_LEAST_ZLIB_1_2_2_1
+ /* Zlib 1.2.2.1 or better allows a dictionary with raw inflate */
+ if (s->WindowBits < 0) {
+ err = inflateSetDictionary(&(s->stream),
+ (const Bytef*)SvPVbyte_nolen(dictionary),
+ SvCUR(dictionary));
+ if (err != Z_OK) {
+ Safefree(s) ;
+ s = NULL ;
+ }
+ }
+ else
+#endif
/* Dictionary specified - take a copy for use in inflate */
s->dictionary = newSVsv(dictionary) ;
}
}
s->bytesInflated = 0;
- while (1) {
+ RETVAL = Z_OK;
+ while (RETVAL == Z_OK) {
if (s->stream.avail_out == 0 ) {
/* out of space in the output buffer so make it bigger */
Sv_Grow(output, SvLEN(output) + bufinc) ;
SvCUR(s->dictionary));
}
- if (RETVAL != Z_OK)
- break;
}
#ifdef NEED_DUMMY_BYTE_AT_END
if (eof && RETVAL == Z_OK) {