Closed pmqs closed 4 years ago
Proposed fix from RT 132734
From 98965db75ff7d9b159fa1948f16fac6c3b20ebb4 Mon Sep 17 00:00:00 2001
From: Eric Wong <p5p@yhbt.net>
Date: Fri, 29 May 2020 07:58:02 +0000
Subject: [PATCH] fix [RT #132734]
Not sure if this is the most efficient way, but it probably
makes sense to backoff the OOK to avoid growing the destination
buffer and potentially doing a copy anyways via realloc.
---
Zlib.xs | 4 +++-
t/02zlib.t | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/Zlib.xs b/Zlib.xs
index 496b876..67fd847 100644
--- a/Zlib.xs
+++ b/Zlib.xs
@@ -1526,7 +1526,9 @@ inflate (s, buf, output, eof=FALSE)
if (DO_UTF8(output) && !sv_utf8_downgrade(output, 1))
croak("Wide character in Compress::Raw::Zlib::Inflate::inflate output parameter");
#endif
- if((s->flags & FLAG_APPEND) != FLAG_APPEND) {
+ if((s->flags & FLAG_APPEND) == FLAG_APPEND) {
+ SvOOK_off(output);
+ } else {
SvCUR_set(output, 0);
}
diff --git a/t/02zlib.t b/t/02zlib.t
index f01aafe..50bc2db 100644
--- a/t/02zlib.t
+++ b/t/02zlib.t
@@ -761,7 +761,7 @@ if ($] >= 5.005)
cmp_ok $Z, 'eq', '. ' ;
# use Devel::Peek ; Dump($Z) ; # shows OOK flag
- if (1) { # workaround
+ if (0) { # workaround
my $prev = $Z;
undef $Z ;
$Z = $prev ;
Issue reproduced with first patch https://github.com/pmqs/IO-Compress/issues/18#issue-627351800
t/000prereq.t ...... # Running Perl version 5.030002
t/000prereq.t ...... ok
t/01version.t ...... ok
t/02zlib.t ......... 1/334
# Failed test (t/02zlib.t at line 776)
# got: '. I.m a HAL 9000 computer'
# expected: '. I am a HAL 9000 computer'
# Looks like you failed 1 test of 334.
t/02zlib.t ......... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/334 subtests
t/07bufsize.t ...... skipped: Lengthy Tests Disabled
t/09limitoutput.t .. ok
t/18lvalue.t ....... ok
t/19nonpv.t ........ ok
t/99pod.t .......... ok
t/meta-json.t ...... skipped: Test::CPAN::Meta::JSON required for testing META.json
t/meta-yaml.t ...... skipped: Test::CPAN::Meta required for testing META.yml
Proposed fix in https://github.com/pmqs/IO-Compress/issues/18#issuecomment-636314444 looks ok with Raw-Zlib
t/000prereq.t ...... # Running Perl version 5.030002
t/000prereq.t ...... ok
t/01version.t ...... ok
t/02zlib.t ......... ok
t/07bufsize.t ...... skipped: Lengthy Tests Disabled
t/09limitoutput.t .. ok
t/18lvalue.t ....... ok
t/19nonpv.t ........ ok
t/99pod.t .......... ok
t/meta-json.t ...... skipped: Test::CPAN::Meta::JSON required for testing META.json
t/meta-yaml.t ...... skipped: Test::CPAN::Meta required for testing META.yml
All tests successful.
Files=10, Tests=498, 1 wallclock secs ( 0.06 usr 0.02 sys + 0.67 cusr 0.07 csys = 0.82 CPU)
Issue is also present in deflate & flush
Issues fixed in release 2.094
Original Issue report from RT 132734