|
Lines 7-12
Link Here
|
| 7 |
//======================================================================== |
7 |
//======================================================================== |
| 8 |
|
8 |
|
| 9 |
#include <aconf.h> |
9 |
#include <aconf.h> |
|
|
10 |
#include <limits.h> |
| 10 |
|
11 |
|
| 11 |
#ifdef USE_GCC_PRAGMAS |
12 |
#ifdef USE_GCC_PRAGMAS |
| 12 |
#pragma implementation |
13 |
#pragma implementation |
|
Lines 681-689
JBIG2Bitmap::JBIG2Bitmap(Guint segNumA,
Link Here
|
| 681 |
w = wA; |
682 |
w = wA; |
| 682 |
h = hA; |
683 |
h = hA; |
| 683 |
line = (wA + 7) >> 3; |
684 |
line = (wA + 7) >> 3; |
| 684 |
// need to allocate one extra guard byte for use in combine() |
685 |
|
| 685 |
data = (Guchar *)gmalloc(h * line + 1); |
686 |
if (h < 0 || line <= 0 || h >= INT_MAX / line) { |
| 686 |
data[h * line] = 0; |
687 |
data = NULL; |
|
|
688 |
} |
| 689 |
else { |
| 690 |
// need to allocate one extra guard byte for use in combine() |
| 691 |
data = (Guchar *)gmalloc(h * line + 1); |
| 692 |
data[h * line] = 0; |
| 693 |
} |
| 687 |
} |
694 |
} |
| 688 |
|
695 |
|
| 689 |
JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): |
696 |
JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap): |
|
Lines 692-697
JBIG2Bitmap::JBIG2Bitmap(Guint segNumA,
Link Here
|
| 692 |
w = bitmap->w; |
699 |
w = bitmap->w; |
| 693 |
h = bitmap->h; |
700 |
h = bitmap->h; |
| 694 |
line = bitmap->line; |
701 |
line = bitmap->line; |
|
|
702 |
|
| 703 |
if (h < 0 || line <= 0 || h >= INT_MAX / line) { |
| 704 |
data = NULL; |
| 705 |
return; |
| 706 |
} |
| 707 |
|
| 695 |
// need to allocate one extra guard byte for use in combine() |
708 |
// need to allocate one extra guard byte for use in combine() |
| 696 |
data = (Guchar *)gmalloc(h * line + 1); |
709 |
data = (Guchar *)gmalloc(h * line + 1); |
| 697 |
memcpy(data, bitmap->data, h * line); |
710 |
memcpy(data, bitmap->data, h * line); |
|
Lines 720-726
JBIG2Bitmap *JBIG2Bitmap::getSlice(Guint
Link Here
|
| 720 |
} |
733 |
} |
| 721 |
|
734 |
|
| 722 |
void JBIG2Bitmap::expand(int newH, Guint pixel) { |
735 |
void JBIG2Bitmap::expand(int newH, Guint pixel) { |
| 723 |
if (newH <= h) { |
736 |
if (newH <= h || line <= 0 || newH >= INT_MAX / line) { |
| 724 |
return; |
737 |
return; |
| 725 |
} |
738 |
} |
| 726 |
// need to allocate one extra guard byte for use in combine() |
739 |
// need to allocate one extra guard byte for use in combine() |
|
Lines 2305-2310
void JBIG2Stream::readHalftoneRegionSeg(
Link Here
|
| 2305 |
error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment"); |
2318 |
error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment"); |
| 2306 |
return; |
2319 |
return; |
| 2307 |
} |
2320 |
} |
|
|
2321 |
if (gridH == 0 || gridW >= INT_MAX / gridH) { |
| 2322 |
error(getPos(), "Bad size in JBIG2 halftone segment"); |
| 2323 |
return; |
| 2324 |
} |
| 2325 |
if (w == 0 || h >= INT_MAX / w) { |
| 2326 |
error(getPos(), "Bad size in JBIG2 bitmap segment"); |
| 2327 |
return; |
| 2328 |
} |
| 2329 |
|
| 2308 |
patternDict = (JBIG2PatternDict *)seg; |
2330 |
patternDict = (JBIG2PatternDict *)seg; |
| 2309 |
bpp = 0; |
2331 |
bpp = 0; |
| 2310 |
i = 1; |
2332 |
i = 1; |
|
Lines 2936-2941
JBIG2Bitmap *JBIG2Stream::readGenericRef
Link Here
|
| 2936 |
JBIG2BitmapPtr tpgrCXPtr0, tpgrCXPtr1, tpgrCXPtr2; |
2958 |
JBIG2BitmapPtr tpgrCXPtr0, tpgrCXPtr1, tpgrCXPtr2; |
| 2937 |
int x, y, pix; |
2959 |
int x, y, pix; |
| 2938 |
|
2960 |
|
|
|
2961 |
if (w < 0 || h <= 0 || w >= INT_MAX / h) |
| 2962 |
return NULL; |
| 2963 |
|
| 2939 |
bitmap = new JBIG2Bitmap(0, w, h); |
2964 |
bitmap = new JBIG2Bitmap(0, w, h); |
| 2940 |
bitmap->clearToZero(); |
2965 |
bitmap->clearToZero(); |
| 2941 |
|
2966 |
|