Skip to content

Commit e3dc0a8

Browse files
committed
Avoid undefined behavior in gzwrite.c.
Adding to NULL is undefined.
1 parent bb0c497 commit e3dc0a8

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

gzwrite.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,8 @@ local int gz_vacate(gz_statep state) {
383383
z_streamp strm;
384384

385385
strm = &(state->strm);
386-
if (strm->next_in + strm->avail_in <= state->in + state->size)
386+
if (strm->next_in == NULL ||
387+
strm->next_in + strm->avail_in <= state->in + state->size)
387388
return 0;
388389
(void)gz_comp(state, Z_NO_FLUSH);
389390
if (strm->avail_in == 0) {

0 commit comments

Comments
 (0)