Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
35 magnus 1
From: Ian Jackson <ijackson@chiark.greenend.org.uk>
2
Applied-Upstream: no
3
Bug-Debian: http://bugs.debian.org/579604
4
Subject: oop-read.h bugfixes
5
 
6
Some years ago I contributed a feature for reading lines and records
7
to liboop: oop-read.h and read.c.  Since it took a while for that
8
feature to make it into distributed versions, for a long time I've
9
been using my own copy of the source file.  It seems that I fixed a
10
couple of bugs in my copy which are still in the Debian package.  I
11
can't find any record of me having told anyone about them and now I
12
find that 1.0-6 still has the bugs.
13
 
14
There are two fixes:
15
 * Initialise "rd->discard" properly
16
 * Avoid rd->neednotcheck becoming negative
17
 
18
--- a/read.c
19
+++ b/read.c
20
@@ -114,6 +114,7 @@ oop_read *oop_rd_new(oop_source *oop, oo
21
   rd->allocbuf= 0;
22
   rd->used= 0;
23
   rd->alloc= buf ? bufsz : 0;
24
+  rd->discard= 0;
25
   rd->neednotcheck= 0;
26
   rd->displacedchar= -1;
27
   rd->style= *OOP_RD_STYLE_IMMED;
28
@@ -235,7 +236,11 @@ static void *on_process(oop_source *oop,
29
 
30
   if (rd->discard) {
31
     rd->used -= rd->discard;
32
-    rd->neednotcheck -= rd->discard;
33
+    if (rd->neednotcheck > rd->discard) {
34
+      rd->neednotcheck -= rd->discard;
35
+    } else {
36
+      rd->neednotcheck= 0;
37
+    }
38
     memmove(buf, buf + rd->discard, rd->used);
39
     rd->discard= 0;
40
   }