Skip to content

Commit

Permalink
src: fix coverity report
Browse files Browse the repository at this point in the history
Fix coverity report about possibly dereferencing
a null. If the the buffer.data != nullptr
check indicates that the buffer was null, then
relying on the value in buffer_size is no longer
safe. The later call to uv_pipe_getpeername
depends on the buffer_size being correct to
avoid deferencing buffer.data if it is not
big enough.

Signed-off-by: Michael Dawson <[email protected]>

PR-URL: nodejs/node#42663
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
mhdawson authored and guangwong committed Oct 10, 2022
1 parent a61d520 commit bd7eff3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/node_report_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ static void ReportPipeEndpoints(uv_handle_t* h, JSONWriter* writer) {
buffer = MallocedBuffer<char>(buffer_size);
if (buffer.data != nullptr) {
rc = uv_pipe_getsockname(&handle->pipe, buffer.data, &buffer_size);
} else {
buffer_size = 0;
}
}
if (rc == 0 && buffer_size != 0 && buffer.data != nullptr) {
Expand Down

0 comments on commit bd7eff3

Please sign in to comment.