Skip to content

Commit

Permalink
src: fix use-after-return in zlib bindings
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bnoordhuis authored and MylesBorins committed Jul 12, 2016
1 parent b3811fd commit 8be9d0a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/node_zlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ class ZCtx : public AsyncWrap {

if (args[1]->IsNull()) {
// just a flush
Bytef nada[1] = { 0 };
in = nada;
in = nullptr;
in_len = 0;
in_off = 0;
} else {
Expand Down

0 comments on commit 8be9d0a

Please sign in to comment.