changeset 2372:d68e6f302855 trunk

[svn] - that should have been in vfs_fread
author nenolod
date Sat, 20 Jan 2007 03:39:28 -0800
parents 3b8b7d4dc10b
children ad1d7687814c
files ChangeLog src/audacious/vfs_buffered_file.c
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jan 20 03:07:30 2007 -0800
+++ b/ChangeLog	Sat Jan 20 03:39:28 2007 -0800
@@ -1,3 +1,11 @@
+2007-01-20 11:07:30 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [3752]
+  - possible fix for VFSBufferedFile crash
+  
+  trunk/src/audacious/vfs_buffered_file.c |    7 +++++++
+  1 file changed, 7 insertions(+)
+
+
 2007-01-20 05:26:43 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [3750]
   - turn off VFS debugging notices
--- a/src/audacious/vfs_buffered_file.c	Sat Jan 20 03:07:30 2007 -0800
+++ b/src/audacious/vfs_buffered_file.c	Sat Jan 20 03:39:28 2007 -0800
@@ -55,6 +55,13 @@
 {
     VFSBufferedFile *handle = (VFSBufferedFile *) file->handle;
 
+    /* is this request within the buffered area, or should we switch to 
+     * an FD? --nenolod
+     */
+    if ((vfs_ftell(handle->buffer)) + (size * nmemb) >= 
+	((VFSBuffer *) handle->buffer->handle)->size)
+        handle->which = TRUE;
+
     return vfs_fread(i_ptr, size, nmemb, handle->which == TRUE ? handle->fd : handle->buffer);
 }
 
@@ -77,7 +84,7 @@
     /* is this request within the buffered area, or should we switch to 
      * an FD? --nenolod
      */
-    if ((vfs_ftell(handle->buffer)) + (size * nmemb) >= 
+    if ((vfs_ftell(handle->buffer)) + 1 >= 
 	((VFSBuffer *) handle->buffer->handle)->size)
         handle->which = TRUE;