lib/pdf: make startPage() upstream compatible
[swftools.git] / lib / pdf / xpdf-changes.patch
index 75f89a6..ddbd0cd 100644 (file)
        if (!strcmp(tok3, "[")) {
          i = 0;
          while (pst->getToken(tok1, sizeof(tok1), &n1) &&
---- xpdf/CoreOutputDev.cc.orig 2010-05-18 11:22:18.000000000 -0700
-+++ xpdf/CoreOutputDev.cc      2010-05-18 11:22:18.000000000 -0700
-@@ -57,5 +57,5 @@
- void CoreOutputDev::clear() {
-   startDoc(NULL);
--  startPage(0, NULL);
-+  startPage(0, NULL, 0,0,0,0);
- }
+@@ -320,7 +327,13 @@
+   if (code >= mapLen) {
+     oldLen = mapLen;
+     mapLen = (code + 256) & ~255;
++    Unicode *oldmap;
+     map = (Unicode *)greallocn(map, mapLen, sizeof(Unicode));
++    if(!map) {
++       /* we sometimes get overflows for files trying to use 0xffffffff as charcode */
++       map = oldmap;
++       return;
++    }
+     for (i = oldLen; i < mapLen; ++i) {
+       map[i] = 0;
+     }
 --- xpdf/Decrypt.cc.orig       2010-05-18 11:22:18.000000000 -0700
 +++ xpdf/Decrypt.cc    2010-05-18 11:22:18.000000000 -0700
 @@ -596,6 +596,7 @@
      }
 --- xpdf/Gfx.cc.orig   2010-05-18 11:22:18.000000000 -0700
 +++ xpdf/Gfx.cc        2010-05-18 11:22:18.000000000 -0700
-@@ -454,7 +454,11 @@
-   fontChanged = gFalse;
-   clip = clipNone;
-   ignoreUndef = 0;
--  out->startPage(pageNum, state);
-+  if(cropBox) {
-+      out->startPage(pageNum, state, cropBox->x1,cropBox->y1,cropBox->x2,cropBox->y2);
-+  } else {
-+      out->startPage(pageNum, state, 0,0,0,0);
-+  }
-   out->setDefaultCTM(state->getCTM());
-   out->updateAll(state);
-   for (i = 0; i < 6; ++i) {
 @@ -465,6 +469,7 @@
    abortCheckCbkData = abortCheckCbkDataA;
  
    syms = (JBIG2Bitmap **)gmallocn(numSyms, sizeof(JBIG2Bitmap *));
 --- xpdf/JPXStream.cc.orig     2010-05-18 11:22:18.000000000 -0700
 +++ xpdf/JPXStream.cc  2010-05-18 11:22:18.000000000 -0700
+@@ -241,6 +242,12 @@
+   haveCompMap = gFalse;
+   haveChannelDefn = gFalse;
++  img.xSize = 0;
++  img.ySize = 0;
++  img.xOffset = 0;
++  img.yOffset = 0;
++  curX = 0;
++  curY = 0;
+   img.tiles = NULL;
+   bitBuf = 0;
+   bitBufLen = 0;
 @@ -450,6 +450,7 @@
    GBool haveBPC, haveCSMode;
  
  
  class GString;
  class GfxState;
-@@ -94,7 +95,7 @@
-     { return gTrue; }
-   // Start a page.
--  virtual void startPage(int pageNum, GfxState *state) {}
-+  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {}
-   // End a page.
-   virtual void endPage() {}
 --- xpdf/SplashFTFont.cc.orig  2010-05-18 11:22:18.000000000 -0700
 +++ xpdf/SplashFTFont.cc       2010-05-18 11:22:18.000000000 -0700
 @@ -46,6 +46,7 @@
  #include <math.h>
  #include "gfile.h"
  #include "GlobalParams.h"
-@@ -702,7 +703,7 @@
-   nT3Fonts = 0;
- }
--void SplashOutputDev::startPage(int pageNum, GfxState *state) {
-+void SplashOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
-   int w, h;
-   double *ctm;
-   SplashCoord mat[6];
 @@ -2646,9 +2647,9 @@
  
    softMask = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(),
        tBitmap->getPixel(x, y, color);
 --- xpdf/SplashOutputDev.h.orig        2010-05-18 11:22:18.000000000 -0700
 +++ xpdf/SplashOutputDev.h     2010-05-18 11:22:18.000000000 -0700
-@@ -70,7 +70,7 @@
-   //----- initialization and control
-   // Start a page.
--  virtual void startPage(int pageNum, GfxState *state);
-+  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
-   // End a page.
-   virtual void endPage();
 @@ -196,6 +196,9 @@
    virtual void setVectorAntialias(GBool vaa);
  #endif
  #endif
  #include <string.h>
  #include <ctype.h>
+@@ -2456,6 +2460,9 @@
+   // check for an EOB run
+   if (eobRun > 0) {
+     while (i <= scanInfo.lastCoeff) {
++      if(i>=64) {
++        return gFalse;
++      }
+       j = dctZigZag[i++];
+       if (data[j] != 0) {
+       if ((bit = readBit()) == EOF) {
+@@ -2480,6 +2487,9 @@
+     if (c == 0xf0) {
+       k = 0;
+       while (k < 16) {
++        if(i>=64) {
++        return gFalse;
++      }
+       j = dctZigZag[i++];
+       if (data[j] == 0) {
+         ++k;
+@@ -2505,6 +2515,9 @@
+       }
+       eobRun += 1 << j;
+       while (i <= scanInfo.lastCoeff) {
++      if(i>=64) {
++        return gFalse;
++      }
+       j = dctZigZag[i++];
+       if (data[j] != 0) {
+         if ((bit = readBit()) == EOF) {
+@@ -2527,6 +2540,9 @@
+       }
+       k = 0;
+       do {
++      if(i>=64) {
++        return gFalse;
++      }
+       j = dctZigZag[i++];
+       while (data[j] != 0) {
+         if ((bit = readBit()) == EOF) {
+@@ -2535,6 +2551,9 @@
+         if (bit) {
+           data[j] += 1 << scanInfo.al;
+         }
++        if(i>=64) {
++          return gFalse;
++        }
+         j = dctZigZag[i++];
+       }
+       ++k;
 --- xpdf/Stream.h.orig 2010-05-18 11:22:18.000000000 -0700
 +++ xpdf/Stream.h      2010-05-18 11:22:18.000000000 -0700
 @@ -41,7 +41,8 @@
  };
  
  //------------------------------------------------------------------------
---- xpdf/TextOutputDev.cc.orig 2010-05-18 11:22:18.000000000 -0700
-+++ xpdf/TextOutputDev.cc      2010-05-18 11:22:18.000000000 -0700
-@@ -3877,7 +3877,7 @@
-   }
- }
--void TextOutputDev::startPage(int pageNum, GfxState *state) {
-+void TextOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
-   text->startPage(state);
- }
 --- xpdf/TextOutputDev.h.orig  2010-05-18 11:22:18.000000000 -0700
 +++ xpdf/TextOutputDev.h       2010-05-18 11:22:18.000000000 -0700
 @@ -170,6 +170,7 @@
  };
  
  //------------------------------------------------------------------------
-@@ -578,7 +579,7 @@
-   //----- initialization and control
-   // Start a page.
--  virtual void startPage(int pageNum, GfxState *state);
-+  virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
-   // End a page.
-   virtual void endPage();
 --- xpdf/gfile.cc.orig 2010-05-18 11:22:18.000000000 -0700
 +++ xpdf/gfile.cc      2010-05-18 11:22:18.000000000 -0700
 @@ -439,6 +439,52 @@