net: don't return the stream object from onStreamRead

CallJSOnreadMethod expects the return value to be undefined or
a new buffer, so make sure to return nothing, even when an error
causes us to destroy the stream.

Fixes: https://github.com/nodejs/node/issues/34346

PR-URL: https://github.com/nodejs/node/pull/34375
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
Robey Pointer
2020-07-14 20:41:11 -07:00
committed by Anna Henningsen
parent 614298d011
commit c0be31f0ef

View File

@@ -208,7 +208,9 @@ function onStreamRead(arrayBuffer) {
}
if (nread !== UV_EOF) {
return stream.destroy(errnoException(nread, 'read'));
// #34375 CallJSOnreadMethod expects the return value to be a buffer.
stream.destroy(errnoException(nread, 'read'));
return;
}
// Defer this until we actually emit end
@@ -225,8 +227,11 @@ function onStreamRead(arrayBuffer) {
// test-https-truncate test.
if (handle.readStop) {
const err = handle.readStop();
if (err)
return stream.destroy(errnoException(err, 'read'));
if (err) {
// #34375 CallJSOnreadMethod expects the return value to be a buffer.
stream.destroy(errnoException(err, 'read'));
return;
}
}
// Push a null to signal the end of data.