[rygel] core: Don't push more data than we are supposed to



commit 459d1042f93280bf72cbfc63073054350d98bdb2
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Mar 30 18:25:27 2011 +0300

    core: Don't push more data than we are supposed to
    
    This fixes a critical regression in SeekableResponse: We kept on pushing
    content even after seek size was satisfied.

 src/rygel/rygel-http-seekable-response.vala |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/rygel/rygel-http-seekable-response.vala b/src/rygel/rygel-http-seekable-response.vala
index da16660..5192892 100644
--- a/src/rygel/rygel-http-seekable-response.vala
+++ b/src/rygel/rygel-http-seekable-response.vala
@@ -141,8 +141,14 @@ internal class Rygel.HTTPSeekableResponse : Rygel.HTTPResponse {
         });
 
         while (bytes_read > 0) {
-            this.push_data (this.buffer[0:bytes_read]);
-            this.total_length -= bytes_read;
+            var to_push = size_t.min (bytes_read, this.total_length);
+
+            this.push_data (this.buffer[0:to_push]);
+            this.total_length -= to_push;
+
+            if (this.total_length <= 0) {
+                break;
+            }
 
             this.run_continue = read_contents.callback;
             // We return from this call when wrote_chunk signal is emitted



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]