Take more care with a NULL reader1 or writer1 buf.

This commit is contained in:
Nigel Tao committed 2017-09-23 15:32:42 +10:00
1 parent 10b7d5a031
commit 7b6f7384d1
6 files changed
+28 -21

No files matched your search

+8 -7
View File
@@ -671,8 +671,9 @@ puffs_flate_status puffs_flate_decoder_decode(puffs_flate_decoder* self,
v_z = t_0;
if (v_z > 0) {
v_m1 = ((puffs_base_buf1_mark){.ptr = b_wptr_dst});
v_written = puffs_base_make_slice_u8(a_dst.buf->ptr, v_m0.ptr, v_m1.ptr,
b_wptr_dst);
v_written =
puffs_base_make_slice_u8(a_dst.buf ? a_dst.buf->ptr : NULL, v_m0.ptr,
v_m1.ptr, a_dst.buf ? b_wptr_dst : NULL);
if (((uint64_t)(v_written.len)) >= 32768) {
v_written = puffs_base_slice_u8_suffix(v_written, 32768);
puffs_base_slice_u8_copy_from(
@@ -877,7 +878,7 @@ exit:
short_read_src:
if (a_src.limit.ptr_to_len) {
status = PUFFS_FLATE_SUSPENSION_LIMITED_READ;
} else if (a_src.buf->closed) {
} else if (a_src.buf && a_src.buf->closed) {
status = PUFFS_FLATE_ERROR_UNEXPECTED_EOF;
goto exit;
} else {
@@ -1025,7 +1026,7 @@ exit:
short_read_src:
if (a_src.limit.ptr_to_len) {
status = PUFFS_FLATE_SUSPENSION_LIMITED_READ;
} else if (a_src.buf->closed) {
} else if (a_src.buf && a_src.buf->closed) {
status = PUFFS_FLATE_ERROR_UNEXPECTED_EOF;
goto exit;
} else {
@@ -1360,7 +1361,7 @@ exit:
short_read_src:
if (a_src.limit.ptr_to_len) {
status = PUFFS_FLATE_SUSPENSION_LIMITED_READ;
} else if (a_src.buf->closed) {
} else if (a_src.buf && a_src.buf->closed) {
status = PUFFS_FLATE_ERROR_UNEXPECTED_EOF;
goto exit;
} else {
@@ -1671,7 +1672,7 @@ exit:
short_read_src:
if (a_src.limit.ptr_to_len) {
status = PUFFS_FLATE_SUSPENSION_LIMITED_READ;
} else if (a_src.buf->closed) {
} else if (a_src.buf && a_src.buf->closed) {
status = PUFFS_FLATE_ERROR_UNEXPECTED_EOF;
goto exit;
} else {
@@ -2122,7 +2123,7 @@ exit:
short_read_src:
if (a_src.limit.ptr_to_len) {
status = PUFFS_FLATE_SUSPENSION_LIMITED_READ;
} else if (a_src.buf->closed) {
} else if (a_src.buf && a_src.buf->closed) {
status = PUFFS_FLATE_ERROR_UNEXPECTED_EOF;
goto exit;
} else {
+8 -8
View File
@@ -694,7 +694,7 @@ exit:
short_read_src:
if (a_src.limit.ptr_to_len) {
status = PUFFS_GIF_SUSPENSION_LIMITED_READ;
} else if (a_src.buf->closed) {
} else if (a_src.buf && a_src.buf->closed) {
status = PUFFS_GIF_ERROR_UNEXPECTED_EOF;
goto exit;
} else {
@@ -776,7 +776,7 @@ exit:
short_read_src:
if (a_src.limit.ptr_to_len) {
status = PUFFS_GIF_SUSPENSION_LIMITED_READ;
} else if (a_src.buf->closed) {
} else if (a_src.buf && a_src.buf->closed) {
status = PUFFS_GIF_ERROR_UNEXPECTED_EOF;
goto exit;
} else {
@@ -885,7 +885,7 @@ exit:
short_read_src:
if (a_src.limit.ptr_to_len) {
status = PUFFS_GIF_SUSPENSION_LIMITED_READ;
} else if (a_src.buf->closed) {
} else if (a_src.buf && a_src.buf->closed) {
status = PUFFS_GIF_ERROR_UNEXPECTED_EOF;
goto exit;
} else {
@@ -959,7 +959,7 @@ puffs_gif_status puffs_gif_decoder_decode_extension(puffs_gif_decoder* self,
b_rptr_src = b_rend_src;
if (a_src.limit.ptr_to_len) {
status = PUFFS_GIF_SUSPENSION_LIMITED_READ;
} else if (a_src.buf->closed) {
} else if (a_src.buf && a_src.buf->closed) {
status = PUFFS_GIF_ERROR_UNEXPECTED_EOF;
goto exit;
} else {
@@ -997,7 +997,7 @@ exit:
short_read_src:
if (a_src.limit.ptr_to_len) {
status = PUFFS_GIF_SUSPENSION_LIMITED_READ;
} else if (a_src.buf->closed) {
} else if (a_src.buf && a_src.buf->closed) {
status = PUFFS_GIF_ERROR_UNEXPECTED_EOF;
goto exit;
} else {
@@ -1153,7 +1153,7 @@ exit:
short_read_src:
if (a_src.limit.ptr_to_len) {
status = PUFFS_GIF_SUSPENSION_LIMITED_READ;
} else if (a_src.buf->closed) {
} else if (a_src.buf && a_src.buf->closed) {
status = PUFFS_GIF_ERROR_UNEXPECTED_EOF;
goto exit;
} else {
@@ -1311,7 +1311,7 @@ puffs_gif_status puffs_gif_lzw_decoder_decode(puffs_gif_lzw_decoder* self,
self->private_impl.f_stack[4095] = ((uint8_t)(v_c));
}
PUFFS_COROUTINE_SUSPENSION_POINT(3);
if (a_dst.buf->closed) {
if (a_dst.buf && a_dst.buf->closed) {
status = PUFFS_GIF_ERROR_CLOSED_FOR_WRITES;
goto exit;
}
@@ -1387,7 +1387,7 @@ exit:
short_read_src:
if (a_src.limit.ptr_to_len) {
status = PUFFS_GIF_SUSPENSION_LIMITED_READ;
} else if (a_src.buf->closed) {
} else if (a_src.buf && a_src.buf->closed) {
status = PUFFS_GIF_ERROR_UNEXPECTED_EOF;
goto exit;
} else {