Have copy_history32 compare to the wstart pointer.

This commit is contained in:
Nigel Tao committed 2017-10-02 16:08:03 +11:00
1 parent e8eff8f5e4
commit 96a9ab4126
2 files changed
+3 -8

No files matched your search

+2 -6
View File
@@ -452,13 +452,9 @@ func (g *gen) writeCallSuspendibles(b *buffer, n *a.Expr, depth uint32) error {
const wName = "dst"
b.printf("size_t %s%d = (size_t)(%s >> 32);", tPrefix, temp0, scratchName)
// TODO: it's not a BAD_ARGUMENT if we can copy from the sliding window.
//
// TODO: %s%s.buf->ptr might be a NULL pointer dereference. In any
// case, we need to compare the (resumed) distance against the
// b_wstart_dst pointer, not against the beginning of the dst buffer.
b.printf("if (PUFFS_UNLIKELY((%s%d == 0) || (%s%d > (%swptr_%s - %s%s.buf->ptr)))) { "+
b.printf("if (PUFFS_UNLIKELY((%s%d == 0) || (%s%d > (%swptr_%s - %swstart_%s)))) { "+
"status = %sERROR_BAD_ARGUMENT; goto exit; }\n",
tPrefix, temp0, tPrefix, temp0, bPrefix, wName, aPrefix, wName, g.PKGPREFIX)
tPrefix, temp0, tPrefix, temp0, bPrefix, wName, bPrefix, wName, g.PKGPREFIX)
b.printf("uint8_t* %s%d = %swptr_%s - %s%d;\n", tPrefix, temp1, bPrefix, wName, tPrefix, temp0)
b.printf("uint32_t %s%d = (uint32_t)(%s);", tPrefix, temp2, scratchName)
+1 -2
View File
@@ -1319,8 +1319,7 @@ puffs_flate_status puffs_flate_decoder_decode_huffman(
PUFFS_COROUTINE_SUSPENSION_POINT(9);
size_t t_6 =
(size_t)(self->private_impl.c_decode_huffman[0].scratch >> 32);
if (PUFFS_UNLIKELY((t_6 == 0) ||
(t_6 > (b_wptr_dst - a_dst.buf->ptr)))) {
if (PUFFS_UNLIKELY((t_6 == 0) || (t_6 > (b_wptr_dst - b_wstart_dst)))) {
status = PUFFS_FLATE_ERROR_BAD_ARGUMENT;
goto exit;
}