@@ -253,7 +253,6 @@ solv_zchunk_open(FILE *fp, unsigned int streamid)
253253 unsigned int lead_size ;
254254 unsigned int preface_size ;
255255 unsigned int index_size ;
256- unsigned int nchunks ;
257256
258257 zck = solv_calloc (1 , sizeof (* zck ));
259258
@@ -314,7 +313,7 @@ solv_zchunk_open(FILE *fp, unsigned int streamid)
314313 return open_error (zck );
315314 if ((p = getchksum (p , zck -> hdr_end , & zck -> chunk_chk_type , & zck -> chunk_chk_len , & zck -> chunk_chk_id )) == 0 )
316315 return open_error (zck );
317- if ((p = getuint (p , zck -> hdr_end , & nchunks )) == 0 || nchunks < 1 || nchunks > MAX_CHUNK_CNT )
316+ if ((p = getuint (p , zck -> hdr_end , & zck -> nchunks )) == 0 || zck -> nchunks > MAX_CHUNK_CNT )
318317 return open_error (zck );
319318
320319 /* setup decompressor */
@@ -326,10 +325,12 @@ solv_zchunk_open(FILE *fp, unsigned int streamid)
326325
327326 zck -> fp = fp ;
328327 zck -> chunks = p ;
329- zck -> nchunks = 1 ; /* the dict stream */
330328 zck -> streamid = streamid ;
331329 if (streamid == 0 )
332- return zck ;
330+ {
331+ zck -> nchunks = zck -> nchunks ? 1 : 0 ; /* limit to dict chunk */
332+ return zck ;
333+ }
333334
334335 /* setup dictionary */
335336 if (!nextchunk (zck , 0 ))
@@ -339,8 +340,7 @@ solv_zchunk_open(FILE *fp, unsigned int streamid)
339340 }
340341 if (zck -> comp == 2 && zck -> buf_avail )
341342 {
342- zck -> ddict = ZSTD_createDDict (zck -> buf , zck -> buf_avail );
343- if (!zck -> ddict )
343+ if ((zck -> ddict = ZSTD_createDDict (zck -> buf , zck -> buf_avail )) == 0 )
344344 {
345345 zck -> fp = 0 ;
346346 return open_error (zck );
@@ -351,7 +351,6 @@ solv_zchunk_open(FILE *fp, unsigned int streamid)
351351 zck -> buf_avail = 0 ;
352352
353353 /* ready to read the rest of the chunks */
354- zck -> nchunks = nchunks - 1 ; /* subtract 1 for the dict stream */
355354 return zck ;
356355}
357356
0 commit comments