[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: bug in Gnome2::VFS?
- From: Torsten Schoenfeld <kaffeetisch web de>
- To: gtk-perl list <gtk-perl-list gnome org>
- Subject: Re: bug in Gnome2::VFS?
- Date: Sat, 06 Mar 2004 17:26:49 +0100
On Sat, 2004-03-06 at 09:40, James Curbo wrote:
> If I run the attached script, I get this crash:
>
> james pioneer:~$ perl vfstest.pl
> Use of uninitialized value in subtraction (-) at vfstest.pl line 26.
> libgnomevfs-CRITICAL **: file gnome-vfs-socket-buffer.c: line 169
> (gnome_vfs_socket_buffer_read): assertion `buffer != NULL' failed at
> vfstest.pl line 26.
> Segmentation fault
The problem is that sf.net doesn't provide the size of the file you
requested. Thus, $info->{size} is undefined. In cases like that you
have to take another approach: read a certain amount of bytes per
iteration, append everything you get to the buffer and stop when you get
the end-of-file error. The attached patch does that. (The patch also
does s/\$@/\$result/g -- Gnome2::VFS doesn't croak on error.)
All that said, Gnome2::VFS should probably not segfault -- I'll look
into it.
Bye,
-Torsten
--- vfstest_old.pl 2004-03-06 17:22:49.000000000 +0100
+++ vfstest.pl 2004-03-06 17:22:34.000000000 +0100
@@ -11,25 +11,23 @@
my ($result, $handle, $info);
($result, $handle) = Gnome2::VFS->open($url, "read");
-die "Problem: $@" unless $result eq "ok";
+die "Problem: $result" unless $result eq "ok";
($result, $info) = $handle->get_file_info("default");
-die "Problem: $@" unless $result eq "ok";
+die "Problem: $result" unless $result eq "ok";
-my $bytes = $info->{size};
+my $bytes_per_iteration = 1024;
my $bytes_read = 0;
my $buffer = "";
do {
my ($tmp_buffer, $tmp_bytes_read);
- ($result, $tmp_bytes_read, $tmp_buffer) = $handle->read($bytes - $bytes_read);
- die "Problem: $@" unless $result eq "ok";
+ ($result, $tmp_bytes_read, $tmp_buffer) = $handle->read($bytes_per_iteration);
$buffer .= $tmp_buffer;
- $bytes_read += $tmp_bytes_read;
-} while ($result eq "ok" and $bytes_read < $bytes);
+} while ($result eq "ok");
$result = $handle->close();
-die "Problem: $@" unless $result eq "ok";
+die "Problem: $result" unless $result eq "ok";
print $buffer;
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]