提交 a134a60d 编写于 作者: J Junio C Hamano

Merge branch 'jc/perl-cat-blob' into maint-1.8.1

* jc/perl-cat-blob:
  Git.pm: fix cat_blob crashes on large files
......@@ -965,20 +965,22 @@ sub cat_blob {
my $size = $1;
my $blob;
my $bytesRead = 0;
my $bytesLeft = $size;
while (1) {
my $bytesLeft = $size - $bytesRead;
last unless $bytesLeft;
my $bytesToRead = $bytesLeft < 1024 ? $bytesLeft : 1024;
my $read = read($in, $blob, $bytesToRead, $bytesRead);
my $read = read($in, $blob, $bytesToRead);
unless (defined($read)) {
$self->_close_cat_blob();
throw Error::Simple("in pipe went bad");
}
$bytesRead += $read;
unless (print $fh $blob) {
$self->_close_cat_blob();
throw Error::Simple("couldn't write to passed in filehandle");
}
$bytesLeft -= $read;
}
# Skip past the trailing newline.
......@@ -993,11 +995,6 @@ sub cat_blob {
throw Error::Simple("didn't find newline after blob");
}
unless (print $fh $blob) {
$self->_close_cat_blob();
throw Error::Simple("couldn't write to passed in filehandle");
}
return $size;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册