Skip to content

Commit 3026ca0

Browse files
committed
src: fix coverity report
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 <mdawson@devrus.com> PR-URL: #42663 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 6669b38 commit 3026ca0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/node_report_utils.cc

+2
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ static void ReportPipeEndpoints(uv_handle_t* h, JSONWriter* writer) {
9595
buffer = MallocedBuffer<char>(buffer_size);
9696
if (buffer.data != nullptr) {
9797
rc = uv_pipe_getsockname(&handle->pipe, buffer.data, &buffer_size);
98+
} else {
99+
buffer_size = 0;
98100
}
99101
}
100102
if (rc == 0 && buffer_size != 0 && buffer.data != nullptr) {

0 commit comments

Comments
 (0)