New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Patch for fixing _write on invalid objects (Debian bug#746804) [rt.cpan.org #101530] #63
Labels
Comments
Description: Patch for fixing _write on invalid objects
Origin: vendor
Bug-Debian: http://bugs.debian.org/746804
Author: Partha Pratim Mukherjee <ppm.floss@gmail.com>
--- a/lib/IPC/Run.pm
+++ b/lib/IPC/Run.pm
@@ -2465,8 +2465,14 @@ sub _open_pipes {
}
_debug_desc_fd( 'writing to', $pipe ) if _debugging_details;
- my $c = _write( $pipe->{FD}, $$in_ref );
- substr( $$in_ref, 0, $c, '' );
+ if (length $$in_ref && $$in_ref) {
+ my $c = _write( $pipe->{FD}, $$in_ref );
+ substr( $$in_ref, 0, $c, '' );
+ } else {
+ $self->_clobber( $pipe );
+ return undef;
+ }
+
return 1;
};
## Output filters are the first filters |
Reporter also submitted a unit test in debian's systems: # Demonstrate Perl IPC::Run stdin callback problem returning array
# by David Paul Christensen dpchrist@holgerdanske.com
# Public Domain
use strict;
use warnings;
use IPC::Run qw( run );
use Test::More tests => 9;
my @cmd = ("true");
our ($i, @i);
my ($in, @in);
ok( run( \@cmd ) == 1, "no callback"); # 1
ok (run( \@cmd, sub { return undef }) == 1, "undef"); # 2
ok (run( \@cmd, sub { return "" }) == 1, "empty string"); # 3
ok (run( \@cmd, sub { return () }) == 1, "empty array"); # 4
ok (run( \@cmd, sub { return $i }) == 1, "package scalar"); # 5
ok (run( \@cmd, sub { return $in }) == 1, "lexical scalar"); # 6
ok (run( \@cmd, sub { my @a; return @a }) == 1,
"block lexical array"); # 7
ok (run( \@cmd, sub { return @i }) == 1, "package array"); # 8
ok (run( \@cmd, sub { return @in }) == 1, "lexical array"); # 9 |
Merged to master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Migrated from rt.cpan.org#101530 (status was 'new')
Requestors:
Attachments:
From ppm.floss@gmail.com on 2015-01-14 05:59:34:
The text was updated successfully, but these errors were encountered: