From: Michael Wallner Date: Mon, 10 Jan 2022 23:17:30 +0000 (+0100) Subject: fix leak reading partial lobs X-Git-Tag: v0.1.0~33 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=7df4391b817912653896c2cf856187d1df2b3752;p=awesomized%2Fext-ion fix leak reading partial lobs --- diff --git a/ion.c b/ion.c index 8bf7e0a..fe7a38e 100644 --- a/ion.c +++ b/ion.c @@ -1036,9 +1036,7 @@ static void read_part(INTERNAL_FUNCTION_PARAMETERS, read_part_fn fn) RETURN_TRUE; } fail: - if (zstr != Z_STR_P(ref)) { - zend_string_release(zstr); - } + zend_string_release(zstr); ZVAL_EMPTY_STRING(ref); RETURN_FALSE; } diff --git a/tests/LOB/RW.phpt b/tests/LOB/RW.phpt new file mode 100644 index 0000000..fa1a576 --- /dev/null +++ b/tests/LOB/RW.phpt @@ -0,0 +1,48 @@ +--TEST-- +ion\LOB/RW +--EXTENSIONS-- +ion +--FILE-- +TEST +stream_set_blocking($s,false), $s); + +$w = new ion\Writer\Stream\Writer($s[0]); +$w->startLob(ion\Type::CLob); +$w->appendLob(str_repeat("a", 0x1000)); + +$l = 0; +$r = new ion\Reader\Stream\Reader($s[1]); +for ($i = 0; $i < 10; $i++) { + $W=$E=[]; + for ($R=[$s[1]]; stream_select($R, $W, $E, 0); ) { + if ($r->getType() != ion\Type::CLob) + $r->next(); + echo "+"; + $r->readLobPart($b); + $l += strlen($b); + } + echo "-"; + $w->appendLob(str_repeat("a", 0x1000)); +} + +$w->finishLob(); +$w->finish(); + +while ($r->readLobPart($b)) { + echo "."; + $l += strlen($b); +} +echo "\n"; + +$r->next(); +var_dump($r->key(), $l); +?> +DONE +--EXPECTF-- +TEST +%r[-+]+\.+%r +enum(ion\Type::EOF) +int(45056) +DONE