1 --- misc/xpdf-3.02/goo/GString.cc Tue Feb 27 23:05:51 2007
2 +++ misc/build/xpdf-3.02/goo/GString.cc Mon Apr 7 13:16:54 2008
7 - x = floor(x * pow(10, prec) + 0.5);
8 + x = floor(x * pow(10.0, prec) + 0.5);
11 for (j = 0; j < prec && i > 1; ++j) {
12 --- misc/xpdf-3.02/goo/gmem.cc 2007-02-27 23:05:51.000000000 +0100
13 +++ misc/build/xpdf-3.02/goo/gmem.cc 2009-04-22 19:21:14.274507454 +0200
16 unsigned long *trl, *p;
21 + throw GMemException();
23 + fprintf(stderr, "Invalid memory allocation size\n");
30 size1 = gMemDataSize(size);
38 + throw GMemException();
40 + fprintf(stderr, "Invalid memory allocation size\n");
47 if (!(p = malloc(size))) {
55 + throw GMemException();
57 + fprintf(stderr, "Invalid memory allocation size\n");
72 + throw GMemException();
74 + fprintf(stderr, "Invalid memory allocation size\n");
82 --- misc/xpdf-3.02/ms_make.bat Tue Feb 27 23:05:51 2007
83 +++ misc/build/xpdf-3.02/ms_make.bat Mon Apr 7 13:16:54 2008
86 -set CFLAGS=/DWIN32 /I.. /I..\goo /I..\fofi /O2 /nologo
87 +set CFLAGS=/DWIN32 /D_MT /I.. /I..\goo /I..\fofi /O2 /nologo
89 set CXXFLAGS=%CFLAGS% /TP
92 %CXX% %CXXFLAGS% /c pdffonts.cc
93 %CXX% %CXXFLAGS% /c pdfimages.cc
95 +%LIBPROG% /nologo /out:xpdf.lib Annot.obj Array.obj BuiltinFont.obj BuiltinFontTables.obj Catalog.obj CharCodeToUnicode.obj CMap.obj Decrypt.obj Dict.obj Error.obj FontEncodingTables.obj Function.obj Gfx.obj GfxFont.obj GfxState.obj GlobalParams.obj JArithmeticDecoder.obj JBIG2Stream.obj JPXStream.obj Lexer.obj Link.obj NameToCharCode.obj Object.obj Outline.obj OutputDev.obj Page.obj Parser.obj PDFDoc.obj PDFDocEncoding.obj PSTokenizer.obj SecurityHandler.obj Stream.obj UnicodeMap.obj XRef.obj
97 %CXX% %LINKFLAGS% /Fepdftops.exe Annot.obj Array.obj BuiltinFont.obj BuiltinFontTables.obj Catalog.obj CharCodeToUnicode.obj CMap.obj Decrypt.obj Dict.obj Error.obj FontEncodingTables.obj Function.obj Gfx.obj GfxFont.obj GfxState.obj GlobalParams.obj JArithmeticDecoder.obj JBIG2Stream.obj JPXStream.obj Lexer.obj Link.obj NameToCharCode.obj Object.obj Outline.obj OutputDev.obj Page.obj Parser.obj PDFDoc.obj PDFDocEncoding.obj PSOutputDev.obj PSTokenizer.obj SecurityHandler.obj Stream.obj UnicodeMap.obj XRef.obj pdftops.obj ..\fofi\fofi.lib ..\goo\Goo.lib shell32.lib user32.lib gdi32.lib advapi32.lib
99 %CXX% %LINKFLAGS% /Fepdftotext.exe Annot.obj Array.obj BuiltinFont.obj BuiltinFontTables.obj Catalog.obj CharCodeToUnicode.obj CMap.obj Decrypt.obj Dict.obj Error.obj FontEncodingTables.obj Function.obj Gfx.obj GfxFont.obj GfxState.obj GlobalParams.obj JArithmeticDecoder.obj JBIG2Stream.obj JPXStream.obj Lexer.obj Link.obj NameToCharCode.obj Object.obj Outline.obj OutputDev.obj Page.obj Parser.obj PDFDoc.obj PDFDocEncoding.obj PSTokenizer.obj SecurityHandler.obj Stream.obj TextOutputDev.obj UnicodeMap.obj UnicodeTypeTable.obj XRef.obj pdftotext.obj ..\fofi\fofi.lib ..\goo\Goo.lib shell32.lib user32.lib gdi32.lib advapi32.lib
104 -rem --- This part will only work if you have FreeType installed ---
106 -set FT2DIR=..\freetype-2.3.1
107 -set CXXFLAGS=%CXXFLAGS% /I..\splash /I%FT2DIR%\include
110 -%CXX% %CXXFLAGS% /c Splash.cc
111 -%CXX% %CXXFLAGS% /c SplashBitmap.cc
112 -%CXX% %CXXFLAGS% /c SplashClip.cc
113 -%CXX% %CXXFLAGS% /c SplashFTFont.cc
114 -%CXX% %CXXFLAGS% /c SplashFTFontEngine.cc
115 -%CXX% %CXXFLAGS% /c SplashFTFontFile.cc
116 -%CXX% %CXXFLAGS% /c SplashFont.cc
117 -%CXX% %CXXFLAGS% /c SplashFontEngine.cc
118 -%CXX% %CXXFLAGS% /c SplashFontFile.cc
119 -%CXX% %CXXFLAGS% /c SplashFontFileID.cc
120 -%CXX% %CXXFLAGS% /c SplashPath.cc
121 -%CXX% %CXXFLAGS% /c SplashPattern.cc
122 -%CXX% %CXXFLAGS% /c SplashScreen.cc
123 -%CXX% %CXXFLAGS% /c SplashState.cc
124 -%CXX% %CXXFLAGS% /c SplashT1Font.cc
125 -%CXX% %CXXFLAGS% /c SplashT1FontEngine.cc
126 -%CXX% %CXXFLAGS% /c SplashT1FontFile.cc
127 -%CXX% %CXXFLAGS% /c SplashXPath.cc
128 -%CXX% %CXXFLAGS% /c SplashXPathScanner.cc
129 -%LIBPROG% /nologo /out:splash.lib Splash.obj SplashBitmap.obj SplashClip.obj SplashFTFont.obj SplashFTFontEngine.obj SplashFTFontFile.obj SplashFont.obj SplashFontEngine.obj SplashFontFile.obj SplashFontFileID.obj SplashPath.obj SplashPattern.obj SplashScreen.obj SplashState.obj SplashT1Font.obj SplashT1FontEngine.obj SplashT1FontFile.obj SplashXPath.obj SplashXPathScanner.obj
132 -%CXX% %CXXFLAGS% /c SplashOutputDev.cc
133 -%CXX% %CXXFLAGS% /c pdftoppm.cc
135 -%CXX% %LINKFLAGS% /Fepdftoppm.exe Annot.obj Array.obj BuiltinFont.obj BuiltinFontTables.obj Catalog.obj CharCodeToUnicode.obj CMap.obj Decrypt.obj Dict.obj Error.obj FontEncodingTables.obj Function.obj Gfx.obj GfxFont.obj GfxState.obj GlobalParams.obj JArithmeticDecoder.obj JBIG2Stream.obj JPXStream.obj Lexer.obj Link.obj NameToCharCode.obj Object.obj Outline.obj OutputDev.obj Page.obj Parser.obj PDFDoc.obj PDFDocEncoding.obj PSTokenizer.obj SecurityHandler.obj SplashOutputDev.obj Stream.obj UnicodeMap.obj UnicodeTypeTable.obj XRef.obj pdftoppm.obj ..\splash\splash.lib ..\fofi\fofi.lib ..\goo\Goo.lib %FT2DIR%\freetype2.lib shell32.lib user32.lib gdi32.lib advapi32.lib
138 --- misc/xpdf-3.02/xpdf/JBIG2Stream.cc 2007-02-27 23:05:52.000000000 +0100
139 +++ misc/build/xpdf-3.02/xpdf/JBIG2Stream.cc 2009-04-22 19:21:14.286412894 +0200
140 @@ -422,12 +422,14 @@
141 table[i] = table[len];
146 - table[i++].prefix = prefix++;
147 - for (; table[i].rangeLen != jbig2HuffmanEOT; ++i) {
148 - prefix <<= table[i].prefixLen - table[i-1].prefixLen;
149 - table[i].prefix = prefix++;
150 + if (table[0].rangeLen != jbig2HuffmanEOT) {
153 + table[i++].prefix = prefix++;
154 + for (; table[i].rangeLen != jbig2HuffmanEOT; ++i) {
155 + prefix <<= table[i].prefixLen - table[i-1].prefixLen;
156 + table[i].prefix = prefix++;
164 error(str->getPos(), "Bad two dim code in JBIG2 MMR stream");
174 - if (bufLen >= 7 && ((buf >> (bufLen - 7)) & 0x7f) == 0) {
175 + if (bufLen >= 11 && ((buf >> (bufLen - 7)) & 0x7f) == 0) {
177 code = buf << (12 - bufLen);
179 @@ -550,14 +552,15 @@
183 - if (bufLen >= 6 && ((buf >> (bufLen - 6)) & 0x3f) == 0) {
184 + if (bufLen >= 10 && ((buf >> (bufLen - 6)) & 0x3f) == 0) {
186 code = buf << (13 - bufLen);
188 code = buf >> (bufLen - 13);
190 p = &blackTab1[code & 0x7f];
191 - } else if (bufLen >= 4 && ((buf >> (bufLen - 4)) & 0x0f) == 0) {
192 + } else if (bufLen >= 7 && ((buf >> (bufLen - 4)) & 0x0f) == 0 &&
193 + ((buf >> (bufLen - 6)) & 0x03) != 0) {
195 code = buf << (12 - bufLen);
199 line = (wA + 7) >> 3;
200 if (w <= 0 || h <= 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
203 + // force a call to gmalloc(-1), which will throw an exception
207 // need to allocate one extra guard byte for use in combine()
208 data = (Guchar *)gmalloc(h * line + 1);
212 if (w <= 0 || h <= 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
215 + // force a call to gmalloc(-1), which will throw an exception
219 // need to allocate one extra guard byte for use in combine()
220 data = (Guchar *)gmalloc(h * line + 1);
222 inline void JBIG2Bitmap::getPixelPtr(int x, int y, JBIG2BitmapPtr *ptr) {
223 if (y < 0 || y >= h || x >= w) {
225 + ptr->shift = 0; // make gcc happy
226 + ptr->x = 0; // make gcc happy
228 ptr->p = &data[y * line];
231 Guint src0, src1, src, dest, s1, s2, m1, m2, m3;
234 + // check for the pathological case where y = -2^31
235 + if (y < -0x7fffffff) {
241 @@ -1011,8 +1022,13 @@
242 JBIG2SymbolDict::JBIG2SymbolDict(Guint segNumA, Guint sizeA):
243 JBIG2Segment(segNumA)
248 bitmaps = (JBIG2Bitmap **)gmallocn(size, sizeof(JBIG2Bitmap *));
249 + for (i = 0; i < size; ++i) {
252 genericRegionStats = NULL;
253 refinementRegionStats = NULL;
255 @@ -1021,7 +1037,9 @@
258 for (i = 0; i < size; ++i) {
265 if (genericRegionStats) {
266 @@ -1296,6 +1314,13 @@
270 + // check for missing page information segment
271 + if (!pageBitmap && ((segType >= 4 && segType <= 7) ||
272 + (segType >= 20 && segType <= 43))) {
273 + error(getPos(), "First JBIG2 segment associated with a page must be a page information segment");
277 // read the segment data
280 @@ -1411,6 +1436,8 @@
286 // symbol dictionary flags
287 if (!readUWord(&flags)) {
289 @@ -1466,20 +1493,32 @@
290 codeTables = new GList();
292 for (i = 0; i < nRefSegs; ++i) {
293 - seg = findSegment(refSegs[i]);
294 - if (seg->getType() == jbig2SegSymbolDict) {
295 - numInputSyms += ((JBIG2SymbolDict *)seg)->getSize();
296 - } else if (seg->getType() == jbig2SegCodeTable) {
297 - codeTables->append(seg);
298 + if ((seg = findSegment(refSegs[i]))) {
299 + if (seg->getType() == jbig2SegSymbolDict) {
300 + j = ((JBIG2SymbolDict *)seg)->getSize();
301 + if (numInputSyms > UINT_MAX - j) {
302 + error(getPos(), "Too many input symbols in JBIG2 symbol dictionary");
307 + } else if (seg->getType() == jbig2SegCodeTable) {
308 + codeTables->append(seg);
312 + if (numInputSyms > UINT_MAX - numNewSyms) {
313 + error(getPos(), "Too many input symbols in JBIG2 symbol dictionary");
318 // compute symbol code length
321 - while (i < numInputSyms + numNewSyms) {
323 + i = (numInputSyms + numNewSyms) >> 1;
330 // get the input symbol bitmaps
331 @@ -1491,11 +1530,12 @@
333 inputSymbolDict = NULL;
334 for (i = 0; i < nRefSegs; ++i) {
335 - seg = findSegment(refSegs[i]);
336 - if (seg->getType() == jbig2SegSymbolDict) {
337 - inputSymbolDict = (JBIG2SymbolDict *)seg;
338 - for (j = 0; j < inputSymbolDict->getSize(); ++j) {
339 - bitmaps[k++] = inputSymbolDict->getBitmap(j);
340 + if ((seg = findSegment(refSegs[i]))) {
341 + if (seg->getType() == jbig2SegSymbolDict) {
342 + inputSymbolDict = (JBIG2SymbolDict *)seg;
343 + for (j = 0; j < inputSymbolDict->getSize(); ++j) {
344 + bitmaps[k++] = inputSymbolDict->getBitmap(j);
349 @@ -1510,6 +1550,9 @@
350 } else if (huffDH == 1) {
351 huffDHTable = huffTableE;
353 + if (i >= (Guint)codeTables->getLength()) {
354 + goto codeTableError;
356 huffDHTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
359 @@ -1517,17 +1560,26 @@
360 } else if (huffDW == 1) {
361 huffDWTable = huffTableC;
363 + if (i >= (Guint)codeTables->getLength()) {
364 + goto codeTableError;
366 huffDWTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
368 if (huffBMSize == 0) {
369 huffBMSizeTable = huffTableA;
371 + if (i >= (Guint)codeTables->getLength()) {
372 + goto codeTableError;
375 ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
377 if (huffAggInst == 0) {
378 huffAggInstTable = huffTableA;
380 + if (i >= (Guint)codeTables->getLength()) {
381 + goto codeTableError;
384 ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
386 @@ -1560,7 +1612,6 @@
389 // allocate symbol widths storage
391 if (huff && !refAgg) {
392 symWidths = (Guint *)gmallocn(numNewSyms, sizeof(Guint));
394 @@ -1602,6 +1653,10 @@
398 + if (i >= numNewSyms) {
399 + error(getPos(), "Too many symbols in JBIG2 symbol dictionary");
403 // using a collective bitmap, so don't read a bitmap here
404 if (huff && !refAgg) {
405 @@ -1638,6 +1693,10 @@
406 arithDecoder->decodeInt(&refDX, iardxStats);
407 arithDecoder->decodeInt(&refDY, iardyStats);
409 + if (symID >= numInputSyms + i) {
410 + error(getPos(), "Invalid symbol ID in JBIG2 symbol dictionary");
413 refBitmap = bitmaps[symID];
414 bitmaps[numInputSyms + i] =
415 readGenericRefinementRegion(symWidth, symHeight,
416 @@ -1704,6 +1763,12 @@
418 arithDecoder->decodeInt(&run, iaexStats);
420 + if (i + run > numInputSyms + numNewSyms ||
421 + (ex && j + run > numExSyms)) {
422 + error(getPos(), "Too many exported symbols in JBIG2 symbol dictionary");
427 for (cnt = 0; cnt < run; ++cnt) {
428 symbolDict->setBitmap(j++, bitmaps[i++]->copy());
429 @@ -1713,6 +1778,11 @@
433 + if (j != numExSyms) {
434 + error(getPos(), "Too few symbols in JBIG2 symbol dictionary");
439 for (i = 0; i < numNewSyms; ++i) {
440 delete bitmaps[numInputSyms + i];
441 @@ -1735,6 +1805,10 @@
446 + error(getPos(), "Missing code table in JBIG2 symbol dictionary");
450 for (i = 0; i < numNewSyms; ++i) {
451 if (bitmaps[numInputSyms + i]) {
452 @@ -1837,6 +1911,8 @@
455 error(getPos(), "Invalid segment reference in JBIG2 text region");
461 @@ -1871,6 +1947,9 @@
462 } else if (huffFS == 1) {
463 huffFSTable = huffTableG;
465 + if (i >= (Guint)codeTables->getLength()) {
466 + goto codeTableError;
468 huffFSTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
471 @@ -1880,6 +1959,9 @@
472 } else if (huffDS == 2) {
473 huffDSTable = huffTableJ;
475 + if (i >= (Guint)codeTables->getLength()) {
476 + goto codeTableError;
478 huffDSTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
481 @@ -1889,6 +1971,9 @@
482 } else if (huffDT == 2) {
483 huffDTTable = huffTableM;
485 + if (i >= (Guint)codeTables->getLength()) {
486 + goto codeTableError;
488 huffDTTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
491 @@ -1896,6 +1981,9 @@
492 } else if (huffRDW == 1) {
493 huffRDWTable = huffTableO;
495 + if (i >= (Guint)codeTables->getLength()) {
496 + goto codeTableError;
498 huffRDWTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
501 @@ -1903,6 +1991,9 @@
502 } else if (huffRDH == 1) {
503 huffRDHTable = huffTableO;
505 + if (i >= (Guint)codeTables->getLength()) {
506 + goto codeTableError;
508 huffRDHTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
511 @@ -1910,6 +2001,9 @@
512 } else if (huffRDX == 1) {
513 huffRDXTable = huffTableO;
515 + if (i >= (Guint)codeTables->getLength()) {
516 + goto codeTableError;
518 huffRDXTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
521 @@ -1917,11 +2011,17 @@
522 } else if (huffRDY == 1) {
523 huffRDYTable = huffTableO;
525 + if (i >= (Guint)codeTables->getLength()) {
526 + goto codeTableError;
528 huffRDYTable = ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
530 if (huffRSize == 0) {
531 huffRSizeTable = huffTableA;
533 + if (i >= (Guint)codeTables->getLength()) {
534 + goto codeTableError;
537 ((JBIG2CodeTable *)codeTables->get(i++))->getHuffTable();
539 @@ -2016,8 +2116,15 @@
544 + error(getPos(), "Missing code table in JBIG2 text region");
550 error(getPos(), "Unexpected EOF in JBIG2 stream");
554 JBIG2Bitmap *JBIG2Stream::readTextRegion(GBool huff, GBool refine,
555 @@ -2324,8 +2431,8 @@
556 error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment");
559 - seg = findSegment(refSegs[0]);
560 - if (seg->getType() != jbig2SegPatternDict) {
561 + if (!(seg = findSegment(refSegs[0])) ||
562 + seg->getType() != jbig2SegPatternDict) {
563 error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment");
566 @@ -2483,7 +2590,7 @@
569 bitmap = readGenericBitmap(mmr, w, h, templ, tpgdOn, gFalse,
570 - NULL, atx, aty, mmr ? 0 : length - 18);
571 + NULL, atx, aty, mmr ? length - 18 : 0);
573 // combine the region bitmap into the page bitmap
575 @@ -2505,6 +2612,43 @@
576 error(getPos(), "Unexpected EOF in JBIG2 stream");
579 +inline void JBIG2Stream::mmrAddPixels(int a1, int blackPixels,
580 + int *codingLine, int *a0i, int w) {
581 + if (a1 > codingLine[*a0i]) {
583 + error(getPos(), "JBIG2 MMR row is wrong length ({0:d})", a1);
586 + if ((*a0i & 1) ^ blackPixels) {
589 + codingLine[*a0i] = a1;
593 +inline void JBIG2Stream::mmrAddPixelsNeg(int a1, int blackPixels,
594 + int *codingLine, int *a0i, int w) {
595 + if (a1 > codingLine[*a0i]) {
597 + error(getPos(), "JBIG2 MMR row is wrong length ({0:d})", a1);
600 + if ((*a0i & 1) ^ blackPixels) {
603 + codingLine[*a0i] = a1;
604 + } else if (a1 < codingLine[*a0i]) {
606 + error(getPos(), "Invalid JBIG2 MMR code");
609 + while (*a0i > 0 && a1 <= codingLine[*a0i - 1]) {
612 + codingLine[*a0i] = a1;
616 JBIG2Bitmap *JBIG2Stream::readGenericBitmap(GBool mmr, int w, int h,
617 int templ, GBool tpgdOn,
618 GBool useSkip, JBIG2Bitmap *skip,
619 @@ -2517,7 +2661,7 @@
620 JBIG2BitmapPtr atPtr0, atPtr1, atPtr2, atPtr3;
621 int *refLine, *codingLine;
622 int code1, code2, code3;
623 - int x, y, a0, pix, i, refI, codingI;
624 + int x, y, a0i, b1i, blackPixels, pix, i;
626 bitmap = new JBIG2Bitmap(0, w, h);
627 bitmap->clearToZero();
628 @@ -2527,9 +2671,18 @@
632 + if (w > INT_MAX - 2) {
633 + error(getPos(), "Bad width in JBIG2 generic bitmap");
634 + // force a call to gmalloc(-1), which will throw an exception
637 + // 0 <= codingLine[0] < codingLine[1] < ... < codingLine[n] = w
638 + // ---> max codingLine size = w + 1
639 + // refLine has one extra guard entry at the end
640 + // ---> max refLine size = w + 2
641 + codingLine = (int *)gmallocn(w + 1, sizeof(int));
642 refLine = (int *)gmallocn(w + 2, sizeof(int));
643 - codingLine = (int *)gmallocn(w + 2, sizeof(int));
644 - codingLine[0] = codingLine[1] = w;
647 for (y = 0; y < h; ++y) {
649 @@ -2537,128 +2690,157 @@
650 for (i = 0; codingLine[i] < w; ++i) {
651 refLine[i] = codingLine[i];
653 - refLine[i] = refLine[i + 1] = w;
658 - refI = 0; // b1 = refLine[refI]
659 - codingI = 0; // a1 = codingLine[codingI]
667 + // refLine[b1i-1] <= codingLine[a0i] < refLine[b1i] < refLine[b1i+1] <= w
668 + // exception at left edge:
669 + // codingLine[a0i = 0] = refLine[b1i = 0] = 0 is possible
670 + // exception at right edge:
671 + // refLine[b1i] = refLine[b1i+1] = w is possible
672 + while (codingLine[a0i] < w) {
673 code1 = mmrDecoder->get2DCode();
676 - if (refLine[refI] < w) {
677 - a0 = refLine[refI + 1];
681 + mmrAddPixels(refLine[b1i + 1], blackPixels, codingLine, &a0i, w);
682 + if (refLine[b1i + 1] < w) {
690 - code1 += code3 = mmrDecoder->getBlackCode();
691 - } while (code3 >= 64);
694 - code2 += code3 = mmrDecoder->getWhiteCode();
695 - } while (code3 >= 64);
699 - code1 += code3 = mmrDecoder->getWhiteCode();
700 - } while (code3 >= 64);
703 - code2 += code3 = mmrDecoder->getBlackCode();
704 - } while (code3 >= 64);
706 - if (code1 > 0 || code2 > 0) {
707 - a0 = codingLine[codingI++] = a0 + code1;
708 - a0 = codingLine[codingI++] = a0 + code2;
709 - while (refLine[refI] <= a0 && refLine[refI] < w) {
715 - a0 = codingLine[codingI++] = refLine[refI];
716 - if (refLine[refI] < w) {
721 - a0 = codingLine[codingI++] = refLine[refI] + 1;
722 - if (refLine[refI] < w) {
724 - while (refLine[refI] <= a0 && refLine[refI] < w) {
730 - a0 = codingLine[codingI++] = refLine[refI] + 2;
731 - if (refLine[refI] < w) {
733 - while (refLine[refI] <= a0 && refLine[refI] < w) {
741 + code1 += code3 = mmrDecoder->getBlackCode();
742 + } while (code3 >= 64);
744 + code2 += code3 = mmrDecoder->getWhiteCode();
745 + } while (code3 >= 64);
748 + code1 += code3 = mmrDecoder->getWhiteCode();
749 + } while (code3 >= 64);
751 + code2 += code3 = mmrDecoder->getBlackCode();
752 + } while (code3 >= 64);
754 + mmrAddPixels(codingLine[a0i] + code1, blackPixels,
755 + codingLine, &a0i, w);
756 + if (codingLine[a0i] < w) {
757 + mmrAddPixels(codingLine[a0i] + code2, blackPixels ^ 1,
758 + codingLine, &a0i, w);
760 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
765 - a0 = codingLine[codingI++] = refLine[refI] + 3;
766 - if (refLine[refI] < w) {
768 - while (refLine[refI] <= a0 && refLine[refI] < w) {
774 - a0 = codingLine[codingI++] = refLine[refI] - 1;
780 - while (refLine[refI] <= a0 && refLine[refI] < w) {
785 - a0 = codingLine[codingI++] = refLine[refI] - 2;
791 - while (refLine[refI] <= a0 && refLine[refI] < w) {
795 + mmrAddPixels(refLine[b1i] + 3, blackPixels, codingLine, &a0i, w);
797 + if (codingLine[a0i] < w) {
799 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
805 + mmrAddPixels(refLine[b1i] + 2, blackPixels, codingLine, &a0i, w);
807 + if (codingLine[a0i] < w) {
809 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
815 + mmrAddPixels(refLine[b1i] + 1, blackPixels, codingLine, &a0i, w);
817 + if (codingLine[a0i] < w) {
819 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
825 + mmrAddPixels(refLine[b1i], blackPixels, codingLine, &a0i, w);
827 + if (codingLine[a0i] < w) {
829 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
835 - a0 = codingLine[codingI++] = refLine[refI] - 3;
841 - while (refLine[refI] <= a0 && refLine[refI] < w) {
845 + mmrAddPixelsNeg(refLine[b1i] - 3, blackPixels, codingLine, &a0i, w);
847 + if (codingLine[a0i] < w) {
853 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
859 + mmrAddPixelsNeg(refLine[b1i] - 2, blackPixels, codingLine, &a0i, w);
861 + if (codingLine[a0i] < w) {
867 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
873 + mmrAddPixelsNeg(refLine[b1i] - 1, blackPixels, codingLine, &a0i, w);
875 + if (codingLine[a0i] < w) {
881 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < w) {
887 + mmrAddPixels(w, 0, codingLine, &a0i, w);
890 error(getPos(), "Illegal code in JBIG2 MMR bitmap data");
891 + mmrAddPixels(w, 0, codingLine, &a0i, w);
895 - codingLine[codingI++] = w;
898 // convert the run lengths to a bitmap line
900 - while (codingLine[i] < w) {
902 for (x = codingLine[i]; x < codingLine[i+1]; ++x) {
903 bitmap->setPixel(x, y);
905 + if (codingLine[i+1] >= w || codingLine[i+2] >= w) {
911 @@ -2706,7 +2888,9 @@
915 - bitmap->duplicateRow(y, y-1);
917 + bitmap->duplicateRow(y, y-1);
922 @@ -2909,8 +3093,8 @@
926 - seg = findSegment(refSegs[0]);
927 - if (seg->getType() != jbig2SegBitmap) {
928 + if (!(seg = findSegment(refSegs[0])) ||
929 + seg->getType() != jbig2SegBitmap) {
930 error(getPos(), "Bad bitmap reference in JBIG2 generic refinement segment");
933 @@ -3004,6 +3188,10 @@
934 tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2);
935 tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
936 tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
938 + tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = NULL; // make gcc happy
939 + tpgrCXPtr0.shift = tpgrCXPtr1.shift = tpgrCXPtr2.shift = 0;
940 + tpgrCXPtr0.x = tpgrCXPtr1.x = tpgrCXPtr2.x = 0;
943 for (x = 0; x < w; ++x) {
944 @@ -3075,6 +3263,10 @@
945 tpgrCX2 = refBitmap->nextPixel(&tpgrCXPtr2);
946 tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
947 tpgrCX2 = (tpgrCX2 << 1) | refBitmap->nextPixel(&tpgrCXPtr2);
949 + tpgrCXPtr0.p = tpgrCXPtr1.p = tpgrCXPtr2.p = NULL; // make gcc happy
950 + tpgrCXPtr0.shift = tpgrCXPtr1.shift = tpgrCXPtr2.shift = 0;
951 + tpgrCXPtr0.x = tpgrCXPtr1.x = tpgrCXPtr2.x = 0;
954 for (x = 0; x < w; ++x) {
955 --- misc/xpdf-3.02/xpdf/JBIG2Stream.h 2007-02-27 23:05:52.000000000 +0100
956 +++ misc/build/xpdf-3.02/xpdf/JBIG2Stream.h 2009-04-22 19:21:14.293918758 +0200
958 Guint *refSegs, Guint nRefSegs);
959 void readGenericRegionSeg(Guint segNum, GBool imm,
960 GBool lossless, Guint length);
961 + void mmrAddPixels(int a1, int blackPixels,
962 + int *codingLine, int *a0i, int w);
963 + void mmrAddPixelsNeg(int a1, int blackPixels,
964 + int *codingLine, int *a0i, int w);
965 JBIG2Bitmap *readGenericBitmap(GBool mmr, int w, int h,
966 int templ, GBool tpgdOn,
967 GBool useSkip, JBIG2Bitmap *skip,
968 --- misc/xpdf-3.02/xpdf/Makefile.in 2007-02-27 23:05:52.000000000 +0100
969 +++ misc/build/xpdf-3.02/xpdf/Makefile.in 2009-04-22 19:20:56.651099700 +0200
971 SPLASHLIBDIR = ../splash
973 CXXFLAGS = @CXXFLAGS@ @DEFS@ -I.. -I$(GOOSRCDIR) -I$(FOFISRCDIR) -I$(SPLASHSRCDIR) -I$(srcdir) @freetype2_CFLAGS@ @Sgm_CFLAGS@ @Xm_CFLAGS@ @Xt_CFLAGS@ @Xp_CFLAGS@ @Xext_CFLAGS@ @Xpm_CFLAGS@ @t1_CFLAGS@ @libpaper_CFLAGS@ @X_CFLAGS@
979 @@ -107,10 +109,27 @@
980 #------------------------------------------------------------------------
982 all: xpdf$(EXE) pdftops$(EXE) pdftotext$(EXE) pdfinfo$(EXE) \
983 - pdffonts$(EXE) pdftoppm$(EXE) pdfimages$(EXE)
984 + pdffonts$(EXE) pdftoppm$(EXE) pdfimages$(EXE) $(LIBPREFIX)xpdf.a
986 all-no-x: pdftops$(EXE) pdftotext$(EXE) pdfinfo$(EXE) pdffonts$(EXE) \
988 + pdfimages$(EXE) $(LIBPREFIX)xpdf.a
990 +#------------------------------------------------------------------------
992 +XPDFLIB_OBJS = Annot.o Array.o BuiltinFont.o BuiltinFontTables.o Catalog.o \
993 + CharCodeToUnicode.o CMap.o Decrypt.o Dict.o \
994 + Error.o FontEncodingTables.o Function.o Gfx.o GfxFont.o \
995 + GfxState.o GlobalParams.o JArithmeticDecoder.o JBIG2Stream.o \
996 + JPXStream.o Lexer.o Link.o NameToCharCode.o Object.o Outline.o \
997 + OutputDev.o Page.o Parser.o PDFCore.o PDFDoc.o PDFDocEncoding.o \
998 + PSTokenizer.o SecurityHandler.o \
999 + Stream.o UnicodeMap.o \
1000 + UnicodeTypeTable.o XRef.o
1002 +$(LIBPREFIX)xpdf.a: $(XPDFLIB_OBJS)
1003 + rm -f $(LIBPREFIX)xpdf.a
1004 + $(AR) $(LIBPREFIX)xpdf.a $(XPDFLIB_OBJS)
1005 + $(RANLIB) $(LIBPREFIX)xpdf.a
1007 #------------------------------------------------------------------------
1009 --- misc/xpdf-3.02/xpdf/Stream.cc 2007-02-27 23:05:52.000000000 +0100
1010 +++ misc/build/xpdf-3.02/xpdf/Stream.cc 2009-04-22 19:20:56.661311973 +0200
1011 @@ -410,15 +410,13 @@
1014 nVals = width * nComps;
1015 - if (width <= 0 || nComps <= 0 || nBits <= 0 ||
1016 - nComps >= INT_MAX / nBits ||
1017 - width >= INT_MAX / nComps / nBits ||
1018 - nVals * nBits + 7 < 0) {
1021 pixBytes = (nComps * nBits + 7) >> 3;
1022 rowBytes = ((nVals * nBits + 7) >> 3) + pixBytes;
1023 - if (rowBytes <= 0) {
1024 + if (width <= 0 || nComps <= 0 || nBits <= 0 ||
1025 + nComps > gfxColorMaxComps ||
1027 + width >= INT_MAX / nComps || // check for overflow in nVals
1028 + nVals >= (INT_MAX - 7) / nBits) { // check for overflow in rowBytes
1031 predLine = (Guchar *)gmalloc(rowBytes);
1032 @@ -1245,23 +1243,26 @@
1037 - if (columns + 4 <= 0) {
1038 - columns = INT_MAX - 4;
1039 + } else if (columns > INT_MAX - 2) {
1040 + columns = INT_MAX - 2;
1043 endOfBlock = endOfBlockA;
1045 - refLine = (short *)gmallocn(columns + 3, sizeof(short));
1046 - codingLine = (short *)gmallocn(columns + 2, sizeof(short));
1047 + // 0 <= codingLine[0] < codingLine[1] < ... < codingLine[n] = columns
1048 + // ---> max codingLine size = columns + 1
1049 + // refLine has one extra guard entry at the end
1050 + // ---> max refLine size = columns + 2
1051 + codingLine = (int *)gmallocn(columns + 1, sizeof(int));
1052 + refLine = (int *)gmallocn(columns + 2, sizeof(int));
1056 nextLine2D = encoding < 0;
1058 - codingLine[0] = 0;
1059 - codingLine[1] = refLine[2] = columns;
1061 + codingLine[0] = columns;
1067 @@ -1280,9 +1281,9 @@
1069 nextLine2D = encoding < 0;
1071 - codingLine[0] = 0;
1072 - codingLine[1] = columns;
1074 + codingLine[0] = columns;
1079 // skip any initial zero bits and end-of-line marker, and get the 2D
1080 @@ -1299,211 +1300,230 @@
1084 +inline void CCITTFaxStream::addPixels(int a1, int blackPixels) {
1085 + if (a1 > codingLine[a0i]) {
1086 + if (a1 > columns) {
1087 + error(getPos(), "CCITTFax row is wrong length (%d)", a1);
1091 + if ((a0i & 1) ^ blackPixels) {
1094 + codingLine[a0i] = a1;
1098 +inline void CCITTFaxStream::addPixelsNeg(int a1, int blackPixels) {
1099 + if (a1 > codingLine[a0i]) {
1100 + if (a1 > columns) {
1101 + error(getPos(), "CCITTFax row is wrong length (%d)", a1);
1105 + if ((a0i & 1) ^ blackPixels) {
1108 + codingLine[a0i] = a1;
1109 + } else if (a1 < codingLine[a0i]) {
1111 + error(getPos(), "Invalid CCITTFax code");
1115 + while (a0i > 0 && a1 <= codingLine[a0i - 1]) {
1118 + codingLine[a0i] = a1;
1122 int CCITTFaxStream::lookChar() {
1123 short code1, code2, code3;
1125 - GBool err, gotEOL;
1128 + int b1i, blackPixels, i, bits;
1131 - // if at eof just return EOF
1132 - if (eof && codingLine[a0] >= columns) {
1138 // read the next row
1140 - if (codingLine[a0] >= columns) {
1141 + if (outputBits == 0) {
1143 + // if at eof just return EOF
1153 - // a0New = current position in coding line (0 <= a0New <= columns)
1154 - // codingLine[a0] = last change in coding line
1155 - // (black-to-white if a0 is even,
1156 - // white-to-black if a0 is odd)
1157 - // refLine[b1] = next change in reference line of opposite color
1160 - // 0 <= codingLine[a0] <= a0New
1161 - // <= refLine[b1] <= refLine[b1+1] <= columns
1162 - // 0 <= a0 <= columns+1
1164 - // refLine[n] = refLine[n+1] = columns
1165 - // -- for some 1 <= n <= columns+1
1167 - // 0 = codingLine[0] <= codingLine[1] < codingLine[2] < ...
1168 - // < codingLine[n-1] < codingLine[n] = columns
1169 - // -- where 1 <= n <= columns+1
1170 for (i = 0; codingLine[i] < columns; ++i) {
1171 refLine[i] = codingLine[i];
1173 - refLine[i] = refLine[i + 1] = columns;
1175 - a0New = codingLine[a0 = 0] = 0;
1177 + refLine[i++] = columns;
1178 + refLine[i] = columns;
1179 + codingLine[0] = 0;
1184 + // refLine[b1i-1] <= codingLine[a0i] < refLine[b1i] < refLine[b1i+1]
1186 + // exception at left edge:
1187 + // codingLine[a0i = 0] = refLine[b1i = 0] = 0 is possible
1188 + // exception at right edge:
1189 + // refLine[b1i] = refLine[b1i+1] = columns is possible
1190 + while (codingLine[a0i] < columns) {
1191 code1 = getTwoDimCode();
1194 - if (refLine[b1] < columns) {
1195 - a0New = refLine[b1 + 1];
1197 + addPixels(refLine[b1i + 1], blackPixels);
1198 + if (refLine[b1i + 1] < columns) {
1203 - if ((a0 & 1) == 0) {
1204 - code1 = code2 = 0;
1205 + code1 = code2 = 0;
1206 + if (blackPixels) {
1208 - code1 += code3 = getWhiteCode();
1209 + code1 += code3 = getBlackCode();
1210 } while (code3 >= 64);
1212 - code2 += code3 = getBlackCode();
1213 + code2 += code3 = getWhiteCode();
1214 } while (code3 >= 64);
1216 - code1 = code2 = 0;
1218 - code1 += code3 = getBlackCode();
1219 + code1 += code3 = getWhiteCode();
1220 } while (code3 >= 64);
1222 - code2 += code3 = getWhiteCode();
1223 + code2 += code3 = getBlackCode();
1224 } while (code3 >= 64);
1226 - if (code1 > 0 || code2 > 0) {
1227 - if (a0New + code1 <= columns) {
1228 - codingLine[a0 + 1] = a0New + code1;
1230 - codingLine[a0 + 1] = columns;
1233 - if (codingLine[a0] + code2 <= columns) {
1234 - codingLine[a0 + 1] = codingLine[a0] + code2;
1236 - codingLine[a0 + 1] = columns;
1239 - a0New = codingLine[a0];
1240 - while (refLine[b1] <= a0New && refLine[b1] < columns) {
1242 + addPixels(codingLine[a0i] + code1, blackPixels);
1243 + if (codingLine[a0i] < columns) {
1244 + addPixels(codingLine[a0i] + code2, blackPixels ^ 1);
1246 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
1250 + case twoDimVertR3:
1251 + addPixels(refLine[b1i] + 3, blackPixels);
1253 + if (codingLine[a0i] < columns) {
1255 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
1261 - if (refLine[b1] < columns) {
1262 - a0New = codingLine[++a0] = refLine[b1];
1264 - while (refLine[b1] <= a0New && refLine[b1] < columns) {
1266 + case twoDimVertR2:
1267 + addPixels(refLine[b1i] + 2, blackPixels);
1269 + if (codingLine[a0i] < columns) {
1271 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
1275 - a0New = codingLine[++a0] = columns;
1279 - if (refLine[b1] + 1 < columns) {
1280 - a0New = codingLine[++a0] = refLine[b1] + 1;
1282 - while (refLine[b1] <= a0New && refLine[b1] < columns) {
1284 + addPixels(refLine[b1i] + 1, blackPixels);
1286 + if (codingLine[a0i] < columns) {
1288 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
1292 - a0New = codingLine[++a0] = columns;
1295 - case twoDimVertL1:
1296 - if (refLine[b1] - 1 > a0New || (a0 == 0 && refLine[b1] == 1)) {
1297 - a0New = codingLine[++a0] = refLine[b1] - 1;
1299 - while (refLine[b1] <= a0New && refLine[b1] < columns) {
1302 + addPixels(refLine[b1i], blackPixels);
1304 + if (codingLine[a0i] < columns) {
1306 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
1311 - case twoDimVertR2:
1312 - if (refLine[b1] + 2 < columns) {
1313 - a0New = codingLine[++a0] = refLine[b1] + 2;
1315 - while (refLine[b1] <= a0New && refLine[b1] < columns) {
1317 + case twoDimVertL3:
1318 + addPixelsNeg(refLine[b1i] - 3, blackPixels);
1320 + if (codingLine[a0i] < columns) {
1326 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
1330 - a0New = codingLine[++a0] = columns;
1334 - if (refLine[b1] - 2 > a0New || (a0 == 0 && refLine[b1] == 2)) {
1335 - a0New = codingLine[++a0] = refLine[b1] - 2;
1337 - while (refLine[b1] <= a0New && refLine[b1] < columns) {
1339 + addPixelsNeg(refLine[b1i] - 2, blackPixels);
1341 + if (codingLine[a0i] < columns) {
1349 - case twoDimVertR3:
1350 - if (refLine[b1] + 3 < columns) {
1351 - a0New = codingLine[++a0] = refLine[b1] + 3;
1353 - while (refLine[b1] <= a0New && refLine[b1] < columns) {
1355 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
1359 - a0New = codingLine[++a0] = columns;
1362 - case twoDimVertL3:
1363 - if (refLine[b1] - 3 > a0New || (a0 == 0 && refLine[b1] == 3)) {
1364 - a0New = codingLine[++a0] = refLine[b1] - 3;
1366 - while (refLine[b1] <= a0New && refLine[b1] < columns) {
1368 + case twoDimVertL1:
1369 + addPixelsNeg(refLine[b1i] - 1, blackPixels);
1371 + if (codingLine[a0i] < columns) {
1377 + while (refLine[b1i] <= codingLine[a0i] && refLine[b1i] < columns) {
1383 + addPixels(columns, 0);
1385 - codingLine[a0 = 0] = columns;
1389 error(getPos(), "Bad 2D code %04x in CCITTFax stream", code1);
1390 + addPixels(columns, 0);
1394 - } while (codingLine[a0] < columns);
1399 - codingLine[a0 = 0] = 0;
1401 + codingLine[0] = 0;
1404 + while (codingLine[a0i] < columns) {
1407 - code1 += code3 = getWhiteCode();
1408 - } while (code3 >= 64);
1409 - codingLine[a0+1] = codingLine[a0] + code1;
1411 - if (codingLine[a0] >= columns) {
1416 - code2 += code3 = getBlackCode();
1417 - } while (code3 >= 64);
1418 - codingLine[a0+1] = codingLine[a0] + code2;
1420 - if (codingLine[a0] >= columns) {
1422 + if (blackPixels) {
1424 + code1 += code3 = getBlackCode();
1425 + } while (code3 >= 64);
1428 + code1 += code3 = getWhiteCode();
1429 + } while (code3 >= 64);
1431 + addPixels(codingLine[a0i] + code1, blackPixels);
1436 - if (codingLine[a0] != columns) {
1437 - error(getPos(), "CCITTFax row is wrong length (%d)", codingLine[a0]);
1438 - // force the row to be the correct length
1439 - while (codingLine[a0] > columns) {
1442 - codingLine[++a0] = columns;
1446 // byte-align the row
1449 @@ -1562,14 +1582,17 @@
1450 // this if we know the stream contains end-of-line markers because
1451 // the "just plow on" technique tends to work better otherwise
1452 } else if (err && endOfLine) {
1455 + code1 = lookBits(13);
1460 + if ((code1 >> 1) == 0x001) {
1464 - code1 = lookBits(13);
1465 - } while ((code1 >> 1) != 0x001);
1470 @@ -1577,11 +1600,11 @@
1475 - outputBits = codingLine[1] - codingLine[0];
1476 - if (outputBits == 0) {
1478 - outputBits = codingLine[2] - codingLine[1];
1479 + // set up for output
1480 + if (codingLine[0] > 0) {
1481 + outputBits = codingLine[a0i = 0];
1483 + outputBits = codingLine[a0i = 1];
1487 @@ -1589,39 +1612,43 @@
1490 if (outputBits >= 8) {
1491 - ret = ((a0 & 1) == 0) ? 0xff : 0x00;
1492 - if ((outputBits -= 8) == 0) {
1494 - if (codingLine[a0] < columns) {
1495 - outputBits = codingLine[a0 + 1] - codingLine[a0];
1497 + buf = (a0i & 1) ? 0x00 : 0xff;
1499 + if (outputBits == 0 && codingLine[a0i] < columns) {
1501 + outputBits = codingLine[a0i] - codingLine[a0i - 1];
1508 if (outputBits > bits) {
1511 - if ((a0 & 1) == 0) {
1512 - ret |= 0xff >> (8 - i);
1515 + buf |= 0xff >> (8 - bits);
1518 + outputBits -= bits;
1522 - bits -= outputBits;
1523 - if ((a0 & 1) == 0) {
1524 - ret |= (0xff >> (8 - i)) << bits;
1525 + buf <<= outputBits;
1527 + buf |= 0xff >> (8 - outputBits);
1529 + bits -= outputBits;
1532 - if (codingLine[a0] < columns) {
1533 - outputBits = codingLine[a0 + 1] - codingLine[a0];
1534 + if (codingLine[a0i] < columns) {
1536 + outputBits = codingLine[a0i] - codingLine[a0i - 1];
1537 + } else if (bits > 0) {
1542 - } while (bits > 0 && codingLine[a0] < columns);
1548 - buf = black ? (ret ^ 0xff) : ret;
1552 @@ -1663,6 +1690,9 @@
1553 code = 0; // make gcc happy
1555 code = lookBits(12);
1556 + if (code == EOF) {
1559 if ((code >> 5) == 0) {
1560 p = &whiteTab1[code];
1562 @@ -1675,6 +1705,9 @@
1564 for (n = 1; n <= 9; ++n) {
1566 + if (code == EOF) {
1572 @@ -1686,6 +1719,9 @@
1574 for (n = 11; n <= 12; ++n) {
1576 + if (code == EOF) {
1582 @@ -1711,9 +1747,12 @@
1583 code = 0; // make gcc happy
1585 code = lookBits(13);
1586 + if (code == EOF) {
1589 if ((code >> 7) == 0) {
1590 p = &blackTab1[code];
1591 - } else if ((code >> 9) == 0) {
1592 + } else if ((code >> 9) == 0 && (code >> 7) != 0) {
1593 p = &blackTab2[(code >> 1) - 64];
1595 p = &blackTab3[code >> 7];
1596 @@ -1725,6 +1764,9 @@
1598 for (n = 2; n <= 6; ++n) {
1600 + if (code == EOF) {
1606 @@ -1736,6 +1778,9 @@
1608 for (n = 7; n <= 12; ++n) {
1610 + if (code == EOF) {
1616 @@ -1749,6 +1794,9 @@
1618 for (n = 10; n <= 13; ++n) {
1620 + if (code == EOF) {
1626 @@ -1963,6 +2011,12 @@
1627 // allocate a buffer for the whole image
1628 bufWidth = ((width + mcuWidth - 1) / mcuWidth) * mcuWidth;
1629 bufHeight = ((height + mcuHeight - 1) / mcuHeight) * mcuHeight;
1630 + if (bufWidth <= 0 || bufHeight <= 0 ||
1631 + bufWidth > INT_MAX / bufWidth / (int)sizeof(int)) {
1632 + error(getPos(), "Invalid image size in DCT stream");
1636 for (i = 0; i < numComps; ++i) {
1637 frameBuf[i] = (int *)gmallocn(bufWidth * bufHeight, sizeof(int));
1638 memset(frameBuf[i], 0, bufWidth * bufHeight * sizeof(int));
1639 @@ -3038,6 +3092,11 @@
1641 scanInfo.firstCoeff = str->getChar();
1642 scanInfo.lastCoeff = str->getChar();
1643 + if (scanInfo.firstCoeff < 0 || scanInfo.lastCoeff > 63 ||
1644 + scanInfo.firstCoeff > scanInfo.lastCoeff) {
1645 + error(getPos(), "Bad DCT coefficient numbers in scan info block");
1649 scanInfo.ah = (c >> 4) & 0x0f;
1650 scanInfo.al = c & 0x0f;
1651 --- misc/xpdf-3.02/xpdf/Stream.h Tue Feb 27 23:05:52 2007
1652 +++ misc/build/xpdf-3.02/xpdf/Stream.h Mon Apr 21 15:42:50 2008
1653 @@ -528,13 +528,15 @@
1654 int row; // current row
1655 int inputBuf; // input buffer
1656 int inputBits; // number of bits in input buffer
1657 - short *refLine; // reference line changing elements
1658 - int b1; // index into refLine
1659 - short *codingLine; // coding line changing elements
1660 - int a0; // index into codingLine
1661 + int *codingLine; // coding line changing elements
1662 + int *refLine; // reference line changing elements
1663 + int a0i; // index into codingLine
1664 + GBool err; // error on current line
1665 int outputBits; // remaining ouput bits
1666 int buf; // character buffer
1668 + void addPixels(int a1, int black);
1669 + void addPixelsNeg(int a1, int black);
1670 short getTwoDimCode();
1671 short getWhiteCode();
1672 short getBlackCode();