Skip to content

Commit e6a27a7

Browse files
bnoordhuisMyles Borins
authored and
Myles Borins
committed
src: fix use-after-return in zlib bindings
Pointed out by Coverity. Introduced in commit 5b8e1da from September 2011 ("Initial pass at zlib bindings".) The asynchronous version of Write() used a pointer to a stack-allocated buffer on flush. A mitigating factor is that zlib does not dereference the pointer for zero-sized writes but it's still technically UB. PR-URL: #7374 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 61de6e9 commit e6a27a7

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/node_zlib.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ class ZCtx : public AsyncWrap {
145145

146146
if (args[1]->IsNull()) {
147147
// just a flush
148-
Bytef nada[1] = { 0 };
149-
in = nada;
148+
in = nullptr;
150149
in_len = 0;
151150
in_off = 0;
152151
} else {

0 commit comments

Comments
 (0)