From 9f83d275e8ca508785554488f78c460cc07adc4e Mon Sep 17 00:00:00 2001 From: prjanitor Date: Thu, 2 Apr 2026 08:55:24 +0300 Subject: [PATCH] Fix missing error handling for IPC::Open3 in ipc_open3 subroutine Add validation to check if open3() succeeds before attempting to read from filehandles. If open3() fails, $writer, $reader, and $error will be undefined, causing silent failures or crashes when reading from undefined filehandles. Closes #431 --- lib/MIP/System_call.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/MIP/System_call.pm b/lib/MIP/System_call.pm index 8d8af3601..1ed9e0803 100644 --- a/lib/MIP/System_call.pm +++ b/lib/MIP/System_call.pm @@ -108,6 +108,11 @@ sub ipc_open3 { # System call my $pid = open3( $writer, $reader, $error, qq{$command_string} ); + # Check if open3 succeeded + unless (defined $pid) { + croak(qq{open3 failed for command "$command_string": $OS_ERROR}); + } + # Terminate process waitpid $pid, 0 or croak(qq{Child process died: $OS_ERROR});