blob: 1880a241acbd55047f3045479e3ed2160c6e88b5 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001From: Ian Jackson <ijackson@chiark.greenend.org.uk>
2Applied-Upstream: no
3Bug-Debian: http://bugs.debian.org/579604
4Subject: oop-read.h bugfixes
5
6Some years ago I contributed a feature for reading lines and records
7to liboop: oop-read.h and read.c. Since it took a while for that
8feature to make it into distributed versions, for a long time I've
9been using my own copy of the source file. It seems that I fixed a
10couple of bugs in my copy which are still in the Debian package. I
11can't find any record of me having told anyone about them and now I
12find that 1.0-6 still has the bugs.
13
14There 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 }