View | Details | Raw Unified | Return to bug 137156
Collapse All | Expand All

(-)xpdf-2.02/xpdf/Stream.cc.orig (-1 / +32 lines)
Lines 404-421 Link Here
404
404
405
StreamPredictor::StreamPredictor(Stream *strA, int predictorA,
405
StreamPredictor::StreamPredictor(Stream *strA, int predictorA,
406
				 int widthA, int nCompsA, int nBitsA) {
406
				 int widthA, int nCompsA, int nBitsA) {
407
  int totalBits;
408
407
  str = strA;
409
  str = strA;
408
  predictor = predictorA;
410
  predictor = predictorA;
409
  width = widthA;
411
  width = widthA;
410
  nComps = nCompsA;
412
  nComps = nCompsA;
411
  nBits = nBitsA;
413
  nBits = nBitsA;
414
  predLine = NULL;
415
  ok = gFalse;
412
416
413
  nVals = width * nComps;
417
  nVals = width * nComps;
418
  totalBits = nVals * nBits;
419
  if (totalBits == 0 ||
420
      (totalBits / nBits) / nComps != width ||
421
      totalBits + 7 < 0) {
422
    return;
423
  }
414
  pixBytes = (nComps * nBits + 7) >> 3;
424
  pixBytes = (nComps * nBits + 7) >> 3;
415
  rowBytes = ((nVals * nBits + 7) >> 3) + pixBytes;
425
  rowBytes = ((totalBits + 7) >> 3) + pixBytes;
426
  if (rowBytes < 0) {
427
    return;
428
  }
416
  predLine = (Guchar *)gmalloc(rowBytes);
429
  predLine = (Guchar *)gmalloc(rowBytes);
417
  memset(predLine, 0, rowBytes);
430
  memset(predLine, 0, rowBytes);
418
  predIdx = rowBytes;
431
  predIdx = rowBytes;
432
433
  ok = gTrue;
419
}
434
}
420
435
421
StreamPredictor::~StreamPredictor() {
436
StreamPredictor::~StreamPredictor() {
Lines 981-986 Link Here
981
    FilterStream(strA) {
996
    FilterStream(strA) {
982
  if (predictor != 1) {
997
  if (predictor != 1) {
983
    pred = new StreamPredictor(this, predictor, columns, colors, bits);
998
    pred = new StreamPredictor(this, predictor, columns, colors, bits);
999
    if (!pred->isOk()) {
1000
      delete pred;
1001
      pred = NULL;
1002
    }
984
  } else {
1003
  } else {
985
    pred = NULL;
1004
    pred = NULL;
986
  }
1005
  }
Lines 2864-2869 Link Here
2864
  height = read16();
2883
  height = read16();
2865
  width = read16();
2884
  width = read16();
2866
  numComps = str->getChar();
2885
  numComps = str->getChar();
2886
  if (numComps <= 0 || numComps > 4) {
2887
    error(getPos(), "Bad number of components in DCT stream", prec);
2888
    return gFalse;
2889
  }
2890
  if (numComps <= 0 || numComps > 4) {
2891
    error(getPos(), "Bad number of components in DCT stream", prec);
2892
    return gFalse;
2893
  }
2867
  if (prec != 8) {
2894
  if (prec != 8) {
2868
    error(getPos(), "Bad DCT precision %d", prec);
2895
    error(getPos(), "Bad DCT precision %d", prec);
2869
    return gFalse;
2896
    return gFalse;
Lines 3182-3187 Link Here
3182
    FilterStream(strA) {
3209
    FilterStream(strA) {
3183
  if (predictor != 1) {
3210
  if (predictor != 1) {
3184
    pred = new StreamPredictor(this, predictor, columns, colors, bits);
3211
    pred = new StreamPredictor(this, predictor, columns, colors, bits);
3212
    if (!pred->isOk()) {
3213
      delete pred;
3214
      pred = NULL;
3215
    }
3185
  } else {
3216
  } else {
3186
    pred = NULL;
3217
    pred = NULL;
3187
  }
3218
  }
(-)xpdf-2.02/xpdf/Stream.h.orig (+3 lines)
Lines 225-230 Link Here
225
225
226
  ~StreamPredictor();
226
  ~StreamPredictor();
227
227
228
  GBool isOk() { return ok; }
229
228
  int lookChar();
230
  int lookChar();
229
  int getChar();
231
  int getChar();
230
232
Lines 242-247 Link Here
242
  int rowBytes;			// bytes per line
244
  int rowBytes;			// bytes per line
243
  Guchar *predLine;		// line buffer
245
  Guchar *predLine;		// line buffer
244
  int predIdx;			// current index in predLine
246
  int predIdx;			// current index in predLine
247
  GBool ok;
245
};
248
};
246
249
247
//------------------------------------------------------------------------
250
//------------------------------------------------------------------------

Return to bug 137156