Skip to content

Commit

Permalink
Additional upstream fixes for loss of data warnings and errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossanlop committed Aug 13, 2024
1 parent 503704f commit d1850db
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/native/external/zlib-ng/arch/generic/crc32_braid_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ Z_INTERNAL uint32_t PREFIX(crc32_braid)(uint32_t crc, const uint8_t *buf, size_t
#endif
#endif
words += N;
c = ZSWAPWORD(comb);
Assert(comb <= UINT32_MAX, "comb should fit in uint32_t");
c = (uint32_t)ZSWAPWORD(comb);

/* Update the pointer to the remaining bytes to process. */
buf = (const unsigned char *)words;
Expand Down
2 changes: 1 addition & 1 deletion src/native/external/zlib-ng/deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Z_INTERNAL deflate_allocs* alloc_deflate(PREFIX3(stream) *strm, int windowBits,

/* Define sizes */
int window_size = DEFLATE_ADJUST_WINDOW_SIZE((1 << windowBits) * 2);
int prev_size = (1 << windowBits) * sizeof(Pos);
int prev_size = (1 << windowBits) * (int)sizeof(Pos);
int head_size = HASH_SIZE * sizeof(Pos);
int pending_size = lit_bufsize * LIT_BUFS;
int state_size = sizeof(deflate_state);
Expand Down
6 changes: 4 additions & 2 deletions src/native/external/zlib-ng/deflate_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ static inline int zng_tr_tally_dist(deflate_state* s, uint32_t dist, uint32_t le
/* dist: distance of matched string */
/* len: match length-STD_MIN_MATCH */
#ifdef LIT_MEM
s->d_buf[s->sym_next] = dist;
s->l_buf[s->sym_next++] = len;
Assert(dist <= UINT16_MAX, "dist should fit in uint16_t");
Assert(len <= UINT8_MAX, "len should fit in uint8_t");
s->d_buf[s->sym_next] = (uint16_t)dist;
s->l_buf[s->sym_next++] = (uint8_t)len;
#else
s->sym_buf[s->sym_next++] = (uint8_t)(dist);
s->sym_buf[s->sym_next++] = (uint8_t)(dist >> 8);
Expand Down
2 changes: 1 addition & 1 deletion src/native/external/zlib-ng/deflate_rle.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Z_INTERNAL block_state deflate_rle(deflate_state *s, int flush) {
if (match_len >= STD_MIN_MATCH) {
Assert(s->strstart <= UINT16_MAX, "strstart should fit in uint16_t");
Assert(s->match_start <= UINT16_MAX, "match_start should fit in uint16_t");
check_match(s, (Pos)s->strstart, (Pos)s->strstart - 1, match_len);
check_match(s, (Pos)s->strstart, (Pos)(s->strstart - 1), match_len);

bflush = zng_tr_tally_dist(s, 1, match_len - STD_MIN_MATCH);

Expand Down

0 comments on commit d1850db

Please sign in to comment.