@@ -112,30 +112,36 @@ int dfltcc_deflate(
112
112
int soft_bcc ;
113
113
int no_flush ;
114
114
115
- if (!dfltcc_can_deflate (strm ))
115
+ if (!dfltcc_can_deflate (strm )) {
116
+ /* Clear history. */
117
+ if (flush == Z_FULL_FLUSH )
118
+ param -> hl = 0 ;
116
119
return 0 ;
120
+ }
117
121
118
122
again :
119
123
masked_avail_in = 0 ;
120
124
soft_bcc = 0 ;
121
125
no_flush = flush == Z_NO_FLUSH ;
122
126
123
- /* Trailing empty block. Switch to software , except when Continuation Flag
124
- * is set, which means that DFLTCC has buffered some output in the
125
- * parameter block and needs to be called again in order to flush it.
127
+ /* No input data. Return , except when Continuation Flag is set, which means
128
+ * that DFLTCC has buffered some output in the parameter block and needs to
129
+ * be called again in order to flush it.
126
130
*/
127
- if (flush == Z_FINISH && strm -> avail_in == 0 && !param -> cf ) {
128
- if ( param -> bcf ) {
129
- /* A block is still open, and the hardware does not support closing
130
- * blocks without adding data. Thus, close it manually.
131
- */
131
+ if (strm -> avail_in == 0 && !param -> cf ) {
132
+ /* A block is still open, and the hardware does not support closing
133
+ * blocks without adding data. Thus, close it manually.
134
+ */
135
+ if (! no_flush && param -> bcf ) {
132
136
send_eobs (strm , param );
133
137
param -> bcf = 0 ;
134
138
}
135
- return 0 ;
136
- }
137
-
138
- if (strm -> avail_in == 0 && !param -> cf ) {
139
+ /* Let one of deflate_* functions write a trailing empty block. */
140
+ if (flush == Z_FINISH )
141
+ return 0 ;
142
+ /* Clear history. */
143
+ if (flush == Z_FULL_FLUSH )
144
+ param -> hl = 0 ;
139
145
* result = need_more ;
140
146
return 1 ;
141
147
}
@@ -189,7 +195,7 @@ int dfltcc_deflate(
189
195
param -> cvt = CVT_ADLER32 ;
190
196
if (!no_flush )
191
197
/* We need to close a block. Always do this in software - when there is
192
- * no input data, the hardware will not nohor BCC. */
198
+ * no input data, the hardware will not hohor BCC. */
193
199
soft_bcc = 1 ;
194
200
if (flush == Z_FINISH && !param -> bcf )
195
201
/* We are about to open a BFINAL block, set Block Header Final bit
@@ -204,8 +210,8 @@ int dfltcc_deflate(
204
210
param -> sbb = (unsigned int )state -> bi_valid ;
205
211
if (param -> sbb > 0 )
206
212
* strm -> next_out = (Byte )state -> bi_buf ;
207
- if ( param -> hl )
208
- param -> nt = 0 ; /* Honor history */
213
+ /* Honor history and check value */
214
+ param -> nt = 0 ;
209
215
param -> cv = strm -> adler ;
210
216
211
217
/* When opening a block, choose a Huffman-Table Type */
0 commit comments