aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
diff options
context:
space:
mode:
authorDmitry Vasilyev <dvassiliev@accesssoftek.com>2024-07-26 19:12:05 +0400
committerGitHub <noreply@github.com>2024-07-26 19:12:05 +0400
commitf083764ba1ca35016c929683c8a5d918b5048100 (patch)
treeff1d7b3f4ea5983df659c5c8d58fbeab51a951ae /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
parent1e1c8d16153a8b3f53b6a8797a77112ecc289551 (diff)
downloadllvm-f083764ba1ca35016c929683c8a5d918b5048100.zip
llvm-f083764ba1ca35016c929683c8a5d918b5048100.tar.gz
llvm-f083764ba1ca35016c929683c8a5d918b5048100.tar.bz2
[lldb] Optimized lldb-server memory usage (#100666)
MAX_PATH is definitely larger than 6 bytes we are expecting for this message, and could be rather large depending on the target OS (4K for some Linux OSs). Since the buffer gets allocated on the stack we better be conservative and allocate what we actually need.
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 187370e..5d0a3e3 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1145,8 +1145,8 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
if (socket_pipe.CanWrite())
socket_pipe.CloseWriteFileDescriptor();
if (socket_pipe.CanRead()) {
- char port_cstr[PATH_MAX] = {0};
- port_cstr[0] = '\0';
+ // The port number may be up to "65535\0".
+ char port_cstr[6] = {0};
size_t num_bytes = sizeof(port_cstr);
// Read port from pipe with 10 second timeout.
error = socket_pipe.ReadWithTimeout(