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 <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
bnoordhuis authored and Fishrock123 committed Jul 5, 2016
1 parent 2816418 commit ce039c3
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 @@ -149,8 +149,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 ce039c3

Please sign in to comment.