mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
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: https://github.com/nodejs/node/pull/42663 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
7c881b218f
commit
a26fd031bf
1 file changed
+2
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user