Subject: | Remove "uninitialized value" warning wrt buffer tails. |
The $tail variable is only set if there is a short read, but then $str->{buffer_tail} is set to $tail unconditionally later. This results in the possibility (and in our case the actuality) of $str->{buffer_tail} being undefined, resulting in "Use of uninitialized value in concatenation (.) or string at /usr/lib/perl5/File/Rsync.pm line 575." (This is pasted from when I ran with version 0.34 of File::Rsync; the patch is against 0.35.)
My patch simply initializes $tail to ''. You could equally leave $tail undefined and change:
$str->{buffer_tail} = $tail;
to:
$str->{buffer_tail} = $tail if defined $tail;
Debian Linux (Sarge), with stock (0.34) and self-compiled (0.35) File::Rsync on i386. Perl 5.8.4.
HTH.
--- Rsync.pm.orig 2005-01-18 16:46:04.000000000 -0600
+++ Rsync.pm 2005-01-18 16:46:24.000000000 -0600
@@ -548,7 +548,7 @@
if ( $fd->sysread($buffer, $str->{block_size}) ) {
${$str->{data}} .= $buffer;
if ( $str->{handler} ) {
- my $tail;
+ my $tail = '';
$tail = $1 if $buffer =~ s/([^\n]+)\z//s;
foreach my $line ( split /^/m, $str->{buffer_tail}.$buffer ) {
&{$str->{handler}}($line, $str->{name});