[simple-scan] Fix new zlib compresion algorithm that fails if running out of space
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [simple-scan] Fix new zlib compresion algorithm that fails if running out of space
- Date: Sun, 30 Apr 2017 21:36:40 +0000 (UTC)
commit e1154ab6e546ef64aec2eaa7279de151c2a371a5
Author: Robert Ancell <robert ancell canonical com>
Date: Mon May 1 09:36:26 2017 +1200
Fix new zlib compresion algorithm that fails if running out of space
src/book.vala | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/book.vala b/src/book.vala
index db7acc9..c27b60d 100644
--- a/src/book.vala
+++ b/src/book.vala
@@ -172,14 +172,19 @@ public class Book
stream.next_in = data;
stream.next_out = out_data;
- while (stream.avail_in > 0)
+ while (true)
{
- if (stream.deflate (ZLib.Flush.FINISH) == ZLib.Status.STREAM_ERROR)
+ /* Compression complete */
+ if (stream.avail_in == 0)
break;
- }
- if (stream.avail_in > 0)
- return null;
+ /* Out of space */
+ if (stream.avail_out == 0)
+ return null;
+
+ if (stream.deflate (ZLib.Flush.FINISH) == ZLib.Status.STREAM_ERROR)
+ return null;
+ }
var n_written = out_data.length - stream.avail_out;
out_data.resize ((int) n_written);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]