Skip to content

Commit f083764

Browse files
authored
[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.
1 parent 1e1c8d1 commit f083764

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1145,8 +1145,8 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
11451145
if (socket_pipe.CanWrite())
11461146
socket_pipe.CloseWriteFileDescriptor();
11471147
if (socket_pipe.CanRead()) {
1148-
char port_cstr[PATH_MAX] = {0};
1149-
port_cstr[0] = '\0';
1148+
// The port number may be up to "65535\0".
1149+
char port_cstr[6] = {0};
11501150
size_t num_bytes = sizeof(port_cstr);
11511151
// Read port from pipe with 10 second timeout.
11521152
error = socket_pipe.ReadWithTimeout(

0 commit comments

Comments
 (0)