Fix out of bounds access when stdout is empty

This commit is contained in:
Alessandro Mauri
2025-08-18 14:35:32 +02:00
committed by Christoffer Lerno
parent a52b30c951
commit 43163fe2a0

View File

@@ -292,6 +292,7 @@ fn String? execute_stdout_to_buffer(char[] buffer, String[] command_line, SubPro
SubProcess process = process::create(command_line, options, environment)!;
process.join()!;
usz len = process.read_stdout(buffer.ptr, buffer.len)!;
if (len == 0) return "";
return (String)buffer[:len - 1];
}
@@ -529,4 +530,4 @@ fn bool? SubProcess.is_running(&self)
self.join()!;
return false;
$endif
}
}