1 *** ./xpdf/XRef.cc.orig Thu Jul 22 11:04:22 2004
2 --- ./xpdf/XRef.cc Thu Jul 22 11:04:31 2004
6 nObjects = obj1.getInt();
14 nObjects = obj1.getInt();
16 ! if (nObjects <= 0) {
24 first = obj1.getInt();
30 objs = new Object[nObjects];
31 objNums = (int *)gmalloc(nObjects * sizeof(int));
35 offsets[i] = obj2.getInt();
38 + if (objNums[i] < 0 || offsets[i] < 0 ||
39 + (i > 0 && offsets[i] < offsets[i-1])) {
45 while (str->getChar() != EOF) ;
52 if (first + n > size) {
53 for (newSize = size ? 2 * size : 1024;
54 ! first + n > newSize;
56 entries = (XRefEntry *)grealloc(entries, newSize * sizeof(XRefEntry));
57 for (i = size; i < newSize; ++i) {
58 entries[i].offset = 0xffffffff;
63 + if (first < 0 || n < 0 || first + n < 0) {
66 if (first + n > size) {
67 for (newSize = size ? 2 * size : 1024;
68 ! first + n > newSize && newSize > 0;
73 entries = (XRefEntry *)grealloc(entries, newSize * sizeof(XRefEntry));
74 for (i = size; i < newSize; ++i) {
75 entries[i].offset = 0xffffffff;
79 // check for an 'XRefStm' key
80 if (obj.getDict()->lookup("XRefStm", &obj2)->isInt()) {
81 ! pos2 = obj2.getInt();
87 // check for an 'XRefStm' key
88 if (obj.getDict()->lookup("XRefStm", &obj2)->isInt()) {
89 ! pos2 = (Guint)obj2.getInt();
97 newSize = obj.getInt();
102 if (newSize > size) {
103 entries = (XRefEntry *)grealloc(entries, newSize * sizeof(XRefEntry));
104 for (i = size; i < newSize; ++i) {
109 w[i] = obj2.getInt();
111 + if (w[i] < 0 || w[i] > 4) {
122 ! if (!readXRefStreamSection(xrefStr, w, first, n)) {
128 ! if (!readXRefStreamSection(xrefStr, w, 0, size)) {
136 ! if (first < 0 || n < 0 ||
137 ! !readXRefStreamSection(xrefStr, w, first, n)) {
143 ! if (!readXRefStreamSection(xrefStr, w, 0, newSize)) {
150 int type, gen, c, newSize, i, j;
152 if (first + n > size) {
153 for (newSize = size ? 2 * size : 1024;
154 ! first + n > newSize;
156 entries = (XRefEntry *)grealloc(entries, newSize * sizeof(XRefEntry));
157 for (i = size; i < newSize; ++i) {
158 entries[i].offset = 0xffffffff;
161 int type, gen, c, newSize, i, j;
163 + if (first + n < 0) {
166 if (first + n > size) {
167 for (newSize = size ? 2 * size : 1024;
168 ! first + n > newSize && newSize > 0;
173 entries = (XRefEntry *)grealloc(entries, newSize * sizeof(XRefEntry));
174 for (i = size; i < newSize; ++i) {
175 entries[i].offset = 0xffffffff;
179 gen = (gen << 8) + c;
183 ! entries[i].offset = offset;
184 ! entries[i].gen = gen;
185 ! entries[i].type = xrefEntryFree;
188 ! entries[i].offset = offset;
189 ! entries[i].gen = gen;
190 ! entries[i].type = xrefEntryUncompressed;
193 ! entries[i].offset = offset;
194 ! entries[i].gen = gen;
195 ! entries[i].type = xrefEntryCompressed;
204 gen = (gen << 8) + c;
206 ! if (entries[i].offset == 0xffffffff) {
209 ! entries[i].offset = offset;
210 ! entries[i].gen = gen;
211 ! entries[i].type = xrefEntryFree;
214 ! entries[i].offset = offset;
215 ! entries[i].gen = gen;
216 ! entries[i].type = xrefEntryUncompressed;
219 ! entries[i].offset = offset;
220 ! entries[i].gen = gen;
221 ! entries[i].type = xrefEntryCompressed;
232 } else if (isdigit(*p)) {
236 ! } while (*p && isdigit(*p));
240 ! } while (*p && isspace(*p));
245 ! } while (*p && isdigit(*p));
249 ! } while (*p && isspace(*p));
250 ! if (!strncmp(p, "obj", 3)) {
252 ! newSize = (num + 1 + 255) & ~255;
253 ! entries = (XRefEntry *)
254 ! grealloc(entries, newSize * sizeof(XRefEntry));
255 ! for (i = size; i < newSize; ++i) {
256 ! entries[i].offset = 0xffffffff;
257 ! entries[i].type = xrefEntryFree;
261 - if (entries[num].type == xrefEntryFree ||
262 - gen >= entries[num].gen) {
263 - entries[num].offset = pos - start;
264 - entries[num].gen = gen;
265 - entries[num].type = xrefEntryUncompressed;
271 } else if (isdigit(*p)) {
276 ! } while (*p && isdigit(*p));
280 ! } while (*p && isspace(*p));
285 ! } while (*p && isdigit(*p));
289 ! } while (*p && isspace(*p));
290 ! if (!strncmp(p, "obj", 3)) {
292 ! newSize = (num + 1 + 255) & ~255;
294 ! error(-1, "Bad object number");
297 ! entries = (XRefEntry *)
298 ! grealloc(entries, newSize * sizeof(XRefEntry));
299 ! for (i = size; i < newSize; ++i) {
300 ! entries[i].offset = 0xffffffff;
301 ! entries[i].type = xrefEntryFree;
305 ! if (entries[num].type == xrefEntryFree ||
306 ! gen >= entries[num].gen) {
307 ! entries[num].offset = pos - start;
308 ! entries[num].gen = gen;
309 ! entries[num].type = xrefEntryUncompressed;