diff options
-rw-r--r-- | glib/poppler-page.cc | 2 | ||||
-rw-r--r-- | goo/gmem.cc | 22 | ||||
-rw-r--r-- | goo/gmem.h | 2 | ||||
-rw-r--r-- | poppler/ArthurOutputDev.cc | 4 | ||||
-rw-r--r-- | poppler/CairoOutputDev.cc | 14 | ||||
-rw-r--r-- | poppler/GfxState.cc | 8 | ||||
-rw-r--r-- | poppler/PSOutputDev.cc | 6 | ||||
-rw-r--r-- | poppler/SplashOutputDev.cc | 20 | ||||
-rw-r--r-- | splash/Splash.cc | 8 | ||||
-rw-r--r-- | splash/SplashBitmap.cc | 6 | ||||
-rw-r--r-- | splash/SplashFTFont.cc | 2 |
11 files changed, 59 insertions, 35 deletions
diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc index f1dd1336..225c97b2 100644 --- a/glib/poppler-page.cc +++ b/glib/poppler-page.cc | |||
@@ -316,7 +316,7 @@ poppler_page_prepare_output_dev (PopplerPage *page, | |||
316 | 316 | ||
317 | output_dev = page->document->output_dev; | 317 | output_dev = page->document->output_dev; |
318 | cairo_rowstride = cairo_width * 4; | 318 | cairo_rowstride = cairo_width * 4; |
319 | cairo_data = (guchar *) gmalloc (cairo_height * cairo_rowstride); | 319 | cairo_data = (guchar *) gmallocn (cairo_height, cairo_rowstride); |
320 | if (transparent) | 320 | if (transparent) |
321 | memset (cairo_data, 0x00, cairo_height * cairo_rowstride); | 321 | memset (cairo_data, 0x00, cairo_height * cairo_rowstride); |
322 | else | 322 | else |
diff --git a/goo/gmem.cc b/goo/gmem.cc index 298d5ddb..af3e19ef 100644 --- a/goo/gmem.cc +++ b/goo/gmem.cc | |||
@@ -216,6 +216,28 @@ void *gmallocn_checkoverflow(int nObjs, int objSize) GMEM_EXCEP { | |||
216 | return gmallocn(nObjs, objSize, true); | 216 | return gmallocn(nObjs, objSize, true); |
217 | } | 217 | } |
218 | 218 | ||
219 | inline static void *gmallocn3(int a, int b, int c, bool checkoverflow) GMEM_EXCEP { | ||
220 | int n = a * b; | ||
221 | if (b <= 0 || a < 0 || a >= INT_MAX / b) { | ||
222 | #if USE_EXCEPTIONS | ||
223 | throw GMemException(); | ||
224 | #else | ||
225 | fprintf(stderr, "Bogus memory allocation size\n"); | ||
226 | if (checkoverflow) return NULL; | ||
227 | else exit(1); | ||
228 | #endif | ||
229 | } | ||
230 | return gmallocn(n, c, checkoverflow); | ||
231 | } | ||
232 | |||
233 | void *gmallocn3(int a, int b, int c) GMEM_EXCEP { | ||
234 | return gmallocn3(a, b, c, false); | ||
235 | } | ||
236 | |||
237 | void *gmallocn3_checkoverflow(int a, int b, int c) GMEM_EXCEP { | ||
238 | return gmallocn3(a, b, c, true); | ||
239 | } | ||
240 | |||
219 | inline static void *greallocn(void *p, int nObjs, int objSize, bool checkoverflow) GMEM_EXCEP { | 241 | inline static void *greallocn(void *p, int nObjs, int objSize, bool checkoverflow) GMEM_EXCEP { |
220 | int n; | 242 | int n; |
221 | 243 | ||
@@ -72,6 +72,8 @@ extern void *grealloc_checkoverflow(size_t size) GMEM_EXCEP; | |||
72 | */ | 72 | */ |
73 | extern void *gmallocn(int nObjs, int objSize) GMEM_EXCEP; | 73 | extern void *gmallocn(int nObjs, int objSize) GMEM_EXCEP; |
74 | extern void *gmallocn_checkoverflow(int nObjs, int objSize) GMEM_EXCEP; | 74 | extern void *gmallocn_checkoverflow(int nObjs, int objSize) GMEM_EXCEP; |
75 | extern void *gmallocn3(int a, int b, int c) GMEM_EXCEP; | ||
76 | extern void *gmallocn3_checkoverflow(int a, int b, int c) GMEM_EXCEP; | ||
75 | extern void *greallocn(void *p, int nObjs, int objSize) GMEM_EXCEP; | 77 | extern void *greallocn(void *p, int nObjs, int objSize) GMEM_EXCEP; |
76 | extern void *greallocn_checkoverflow(void *p, int nObjs, int objSize) GMEM_EXCEP; | 78 | extern void *greallocn_checkoverflow(void *p, int nObjs, int objSize) GMEM_EXCEP; |
77 | 79 | ||
diff --git a/poppler/ArthurOutputDev.cc b/poppler/ArthurOutputDev.cc index 4f6a1d0f..fe562fe3 100644 --- a/poppler/ArthurOutputDev.cc +++ b/poppler/ArthurOutputDev.cc | |||
@@ -14,7 +14,7 @@ | |||
14 | // under GPL version 2 or later | 14 | // under GPL version 2 or later |
15 | // | 15 | // |
16 | // Copyright (C) 2005 Brad Hards <bradh@frogmouth.net> | 16 | // Copyright (C) 2005 Brad Hards <bradh@frogmouth.net> |
17 | // Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> | 17 | // Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> |
18 | // Copyright (C) 2008 Pino Toscano <pino@kde.org> | 18 | // Copyright (C) 2008 Pino Toscano <pino@kde.org> |
19 | // | 19 | // |
20 | // To see a description of the changes please see the Changelog file that | 20 | // To see a description of the changes please see the Changelog file that |
@@ -751,7 +751,7 @@ void ArthurOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, | |||
751 | QMatrix matrix; | 751 | QMatrix matrix; |
752 | int is_identity_transform; | 752 | int is_identity_transform; |
753 | 753 | ||
754 | buffer = (unsigned char *)gmalloc (width * height * 4); | 754 | buffer = (unsigned char *)gmallocn3(width, height, 4); |
755 | 755 | ||
756 | /* TODO: Do we want to cache these? */ | 756 | /* TODO: Do we want to cache these? */ |
757 | imgStr = new ImageStream(str, width, | 757 | imgStr = new ImageStream(str, width, |
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index 91e1d045..98adb7cb 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc | |||
@@ -16,7 +16,7 @@ | |||
16 | // | 16 | // |
17 | // Copyright (C) 2005-2008 Jeff Muizelaar <jeff@infidigm.net> | 17 | // Copyright (C) 2005-2008 Jeff Muizelaar <jeff@infidigm.net> |
18 | // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> | 18 | // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> |
19 | // Copyright (C) 2005 Albert Astals Cid <aacid@kde.org> | 19 | // Copyright (C) 2005, 2009 Albert Astals Cid <aacid@kde.org> |
20 | // Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru> | 20 | // Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru> |
21 | // Copyright (C) 2006-2008 Carlos Garcia Campos <carlosgc@gnome.org> | 21 | // Copyright (C) 2006-2008 Carlos Garcia Campos <carlosgc@gnome.org> |
22 | // Copyright (C) 2008 Carl Worth <cworth@cworth.org> | 22 | // Copyright (C) 2008 Carl Worth <cworth@cworth.org> |
@@ -611,7 +611,7 @@ void CairoOutputDev::beginString(GfxState *state, GooString *s) | |||
611 | if (!currentFont) | 611 | if (!currentFont) |
612 | return; | 612 | return; |
613 | 613 | ||
614 | glyphs = (cairo_glyph_t *) gmalloc (len * sizeof (cairo_glyph_t)); | 614 | glyphs = (cairo_glyph_t *) gmallocn (len, sizeof (cairo_glyph_t)); |
615 | glyphCount = 0; | 615 | glyphCount = 0; |
616 | } | 616 | } |
617 | 617 | ||
@@ -1461,7 +1461,7 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref, | |||
1461 | 1461 | ||
1462 | int row_stride = (maskWidth + 3) & ~3; | 1462 | int row_stride = (maskWidth + 3) & ~3; |
1463 | unsigned char *maskBuffer; | 1463 | unsigned char *maskBuffer; |
1464 | maskBuffer = (unsigned char *)gmalloc (row_stride * maskHeight); | 1464 | maskBuffer = (unsigned char *)gmallocn (row_stride, maskHeight); |
1465 | unsigned char *maskDest; | 1465 | unsigned char *maskDest; |
1466 | cairo_surface_t *maskImage; | 1466 | cairo_surface_t *maskImage; |
1467 | cairo_pattern_t *maskPattern; | 1467 | cairo_pattern_t *maskPattern; |
@@ -1497,7 +1497,7 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref, | |||
1497 | cairo_matrix_t matrix; | 1497 | cairo_matrix_t matrix; |
1498 | int is_identity_transform; | 1498 | int is_identity_transform; |
1499 | 1499 | ||
1500 | buffer = (unsigned char *)gmalloc (width * height * 4); | 1500 | buffer = (unsigned char *)gmallocn3 (width, height, 4); |
1501 | 1501 | ||
1502 | /* TODO: Do we want to cache these? */ | 1502 | /* TODO: Do we want to cache these? */ |
1503 | imgStr = new ImageStream(str, width, | 1503 | imgStr = new ImageStream(str, width, |
@@ -1586,7 +1586,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s | |||
1586 | 1586 | ||
1587 | int row_stride = (maskWidth + 3) & ~3; | 1587 | int row_stride = (maskWidth + 3) & ~3; |
1588 | unsigned char *maskBuffer; | 1588 | unsigned char *maskBuffer; |
1589 | maskBuffer = (unsigned char *)gmalloc (row_stride * maskHeight); | 1589 | maskBuffer = (unsigned char *)gmallocn (row_stride, maskHeight); |
1590 | unsigned char *maskDest; | 1590 | unsigned char *maskDest; |
1591 | cairo_surface_t *maskImage; | 1591 | cairo_surface_t *maskImage; |
1592 | cairo_pattern_t *maskPattern; | 1592 | cairo_pattern_t *maskPattern; |
@@ -1613,7 +1613,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s | |||
1613 | cairo_matrix_t maskMatrix; | 1613 | cairo_matrix_t maskMatrix; |
1614 | int is_identity_transform; | 1614 | int is_identity_transform; |
1615 | 1615 | ||
1616 | buffer = (unsigned char *)gmalloc (width * height * 4); | 1616 | buffer = (unsigned char *)gmallocn3 (width, height, 4); |
1617 | 1617 | ||
1618 | /* TODO: Do we want to cache these? */ | 1618 | /* TODO: Do we want to cache these? */ |
1619 | imgStr = new ImageStream(str, width, | 1619 | imgStr = new ImageStream(str, width, |
@@ -1705,7 +1705,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, | |||
1705 | cairo_matrix_t matrix; | 1705 | cairo_matrix_t matrix; |
1706 | int is_identity_transform; | 1706 | int is_identity_transform; |
1707 | 1707 | ||
1708 | buffer = (unsigned char *)gmalloc (width * height * 4); | 1708 | buffer = (unsigned char *)gmallocn3 (width, height, 4); |
1709 | 1709 | ||
1710 | /* TODO: Do we want to cache these? */ | 1710 | /* TODO: Do we want to cache these? */ |
1711 | imgStr = new ImageStream(str, width, | 1711 | imgStr = new ImageStream(str, width, |
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc index 8fc8feb5..1ca32895 100644 --- a/poppler/GfxState.cc +++ b/poppler/GfxState.cc | |||
@@ -1849,7 +1849,7 @@ void GfxIndexedColorSpace::getRGBLine(Guchar *in, unsigned int *out, int length) | |||
1849 | int i, j, n; | 1849 | int i, j, n; |
1850 | 1850 | ||
1851 | n = base->getNComps(); | 1851 | n = base->getNComps(); |
1852 | line = (Guchar *) gmalloc (length * n); | 1852 | line = (Guchar *) gmallocn (length, n); |
1853 | for (i = 0; i < length; i++) | 1853 | for (i = 0; i < length; i++) |
1854 | for (j = 0; j < n; j++) | 1854 | for (j = 0; j < n; j++) |
1855 | line[i * n + j] = lookup[in[i] * n + j]; | 1855 | line[i * n + j] = lookup[in[i] * n + j]; |
@@ -4072,7 +4072,7 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode, | |||
4072 | nComps2 = colorSpace2->getNComps(); | 4072 | nComps2 = colorSpace2->getNComps(); |
4073 | lookup2 = indexedCS->getLookup(); | 4073 | lookup2 = indexedCS->getLookup(); |
4074 | colorSpace2->getDefaultRanges(x, y, indexHigh); | 4074 | colorSpace2->getDefaultRanges(x, y, indexHigh); |
4075 | byte_lookup = (Guchar *)gmalloc ((maxPixel + 1) * nComps2); | 4075 | byte_lookup = (Guchar *)gmallocn ((maxPixel + 1), nComps2); |
4076 | for (k = 0; k < nComps2; ++k) { | 4076 | for (k = 0; k < nComps2; ++k) { |
4077 | lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1, | 4077 | lookup[k] = (GfxColorComp *)gmallocn(maxPixel + 1, |
4078 | sizeof(GfxColorComp)); | 4078 | sizeof(GfxColorComp)); |
@@ -4220,7 +4220,7 @@ void GfxImageColorMap::getGrayLine(Guchar *in, Guchar *out, int length) { | |||
4220 | switch (colorSpace->getMode()) { | 4220 | switch (colorSpace->getMode()) { |
4221 | case csIndexed: | 4221 | case csIndexed: |
4222 | case csSeparation: | 4222 | case csSeparation: |
4223 | tmp_line = (Guchar *) gmalloc (length * nComps2); | 4223 | tmp_line = (Guchar *) gmallocn (length, nComps2); |
4224 | for (i = 0; i < length; i++) { | 4224 | for (i = 0; i < length; i++) { |
4225 | for (j = 0; j < nComps2; j++) { | 4225 | for (j = 0; j < nComps2; j++) { |
4226 | tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j]; | 4226 | tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j]; |
@@ -4250,7 +4250,7 @@ void GfxImageColorMap::getRGBLine(Guchar *in, unsigned int *out, int length) { | |||
4250 | switch (colorSpace->getMode()) { | 4250 | switch (colorSpace->getMode()) { |
4251 | case csIndexed: | 4251 | case csIndexed: |
4252 | case csSeparation: | 4252 | case csSeparation: |
4253 | tmp_line = (Guchar *) gmalloc (length * nComps2); | 4253 | tmp_line = (Guchar *) gmallocn (length, nComps2); |
4254 | for (i = 0; i < length; i++) { | 4254 | for (i = 0; i < length; i++) { |
4255 | for (j = 0; j < nComps2; j++) { | 4255 | for (j = 0; j < nComps2; j++) { |
4256 | tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j]; | 4256 | tmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j]; |
diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 9477762e..f02bd98a 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc | |||
@@ -15,7 +15,7 @@ | |||
15 | // | 15 | // |
16 | // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> | 16 | // Copyright (C) 2005 Martin Kretzschmar <martink@gnome.org> |
17 | // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> | 17 | // Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com> |
18 | // Copyright (C) 2006-2008 Albert Astals Cid <aacid@kde.org> | 18 | // Copyright (C) 2006-2009 Albert Astals Cid <aacid@kde.org> |
19 | // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> | 19 | // Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net> |
20 | // Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> | 20 | // Copyright (C) 2007, 2008 Brad Hards <bradh@kde.org> |
21 | // Copyright (C) 2008 Koji Otani <sho@bbr.jp> | 21 | // Copyright (C) 2008 Koji Otani <sho@bbr.jp> |
@@ -2324,7 +2324,7 @@ GooString *PSOutputDev::setupExternalCIDTrueTypeFont(GfxFont *font, GooString *f | |||
2324 | if ((ffTT = FoFiTrueType::load(fileName->getCString(), faceIndex))) { | 2324 | if ((ffTT = FoFiTrueType::load(fileName->getCString(), faceIndex))) { |
2325 | int n = ((GfxCIDFont *)font)->getCIDToGIDLen(); | 2325 | int n = ((GfxCIDFont *)font)->getCIDToGIDLen(); |
2326 | if (n) { | 2326 | if (n) { |
2327 | codeToGID = (Gushort *)gmalloc(n * sizeof(Gushort)); | 2327 | codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort)); |
2328 | memcpy(codeToGID, ((GfxCIDFont *)font)->getCIDToGID(), n * sizeof(Gushort)); | 2328 | memcpy(codeToGID, ((GfxCIDFont *)font)->getCIDToGID(), n * sizeof(Gushort)); |
2329 | } else { | 2329 | } else { |
2330 | codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT, &n); | 2330 | codeToGID = ((GfxCIDFont *)font)->getCodeToGIDMap(ffTT, &n); |
@@ -4503,7 +4503,7 @@ void PSOutputDev::doImageL1Sep(GfxImageColorMap *colorMap, | |||
4503 | width, -height, height); | 4503 | width, -height, height); |
4504 | 4504 | ||
4505 | // allocate a line buffer | 4505 | // allocate a line buffer |
4506 | lineBuf = (Guchar *)gmalloc(4 * width); | 4506 | lineBuf = (Guchar *)gmallocn(width, 4); |
4507 | 4507 | ||
4508 | // set up to process the data stream | 4508 | // set up to process the data stream |
4509 | imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(), | 4509 | imgStr = new ImageStream(str, width, colorMap->getNumPixelComps(), |
diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc index 8d4758a6..dc4661a9 100644 --- a/poppler/SplashOutputDev.cc +++ b/poppler/SplashOutputDev.cc | |||
@@ -15,7 +15,7 @@ | |||
15 | // | 15 | // |
16 | // Copyright (C) 2005 Takashi Iwai <tiwai@suse.de> | 16 | // Copyright (C) 2005 Takashi Iwai <tiwai@suse.de> |
17 | // Copyright (C) 2006 Stefan Schweizer <genstef@gentoo.org> | 17 | // Copyright (C) 2006 Stefan Schweizer <genstef@gentoo.org> |
18 | // Copyright (C) 2006-2008 Albert Astals Cid <aacid@kde.org> | 18 | // Copyright (C) 2006-2009 Albert Astals Cid <aacid@kde.org> |
19 | // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> | 19 | // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> |
20 | // Copyright (C) 2006 Scott Turner <scotty1024@mac.com> | 20 | // Copyright (C) 2006 Scott Turner <scotty1024@mac.com> |
21 | // Copyright (C) 2007 Koji Otani <sho@bbr.jp> | 21 | // Copyright (C) 2007 Koji Otani <sho@bbr.jp> |
@@ -2013,7 +2013,7 @@ void SplashOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, | |||
2013 | break; | 2013 | break; |
2014 | case splashModeRGB8: | 2014 | case splashModeRGB8: |
2015 | case splashModeBGR8: | 2015 | case splashModeBGR8: |
2016 | imgData.lookup = (SplashColorPtr)gmalloc(3 * n); | 2016 | imgData.lookup = (SplashColorPtr)gmallocn(n, 3); |
2017 | for (i = 0; i < n; ++i) { | 2017 | for (i = 0; i < n; ++i) { |
2018 | pix = (Guchar)i; | 2018 | pix = (Guchar)i; |
2019 | colorMap->getRGB(&pix, &rgb); | 2019 | colorMap->getRGB(&pix, &rgb); |
@@ -2023,7 +2023,7 @@ void SplashOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, | |||
2023 | } | 2023 | } |
2024 | break; | 2024 | break; |
2025 | case splashModeXBGR8: | 2025 | case splashModeXBGR8: |
2026 | imgData.lookup = (SplashColorPtr)gmalloc(4 * n); | 2026 | imgData.lookup = (SplashColorPtr)gmallocn(n, 4); |
2027 | for (i = 0; i < n; ++i) { | 2027 | for (i = 0; i < n; ++i) { |
2028 | pix = (Guchar)i; | 2028 | pix = (Guchar)i; |
2029 | colorMap->getRGB(&pix, &rgb); | 2029 | colorMap->getRGB(&pix, &rgb); |
@@ -2035,7 +2035,7 @@ void SplashOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, | |||
2035 | break; | 2035 | break; |
2036 | #if SPLASH_CMYK | 2036 | #if SPLASH_CMYK |
2037 | case splashModeCMYK8: | 2037 | case splashModeCMYK8: |
2038 | imgData.lookup = (SplashColorPtr)gmalloc(4 * n); | 2038 | imgData.lookup = (SplashColorPtr)gmallocn(n, 4); |
2039 | for (i = 0; i < n; ++i) { | 2039 | for (i = 0; i < n; ++i) { |
2040 | pix = (Guchar)i; | 2040 | pix = (Guchar)i; |
2041 | colorMap->getCMYK(&pix, &cmyk); | 2041 | colorMap->getCMYK(&pix, &cmyk); |
@@ -2278,7 +2278,7 @@ void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref, | |||
2278 | break; | 2278 | break; |
2279 | case splashModeRGB8: | 2279 | case splashModeRGB8: |
2280 | case splashModeBGR8: | 2280 | case splashModeBGR8: |
2281 | imgData.lookup = (SplashColorPtr)gmalloc(3 * n); | 2281 | imgData.lookup = (SplashColorPtr)gmallocn(n, 3); |
2282 | for (i = 0; i < n; ++i) { | 2282 | for (i = 0; i < n; ++i) { |
2283 | pix = (Guchar)i; | 2283 | pix = (Guchar)i; |
2284 | colorMap->getRGB(&pix, &rgb); | 2284 | colorMap->getRGB(&pix, &rgb); |
@@ -2288,7 +2288,7 @@ void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref, | |||
2288 | } | 2288 | } |
2289 | break; | 2289 | break; |
2290 | case splashModeXBGR8: | 2290 | case splashModeXBGR8: |
2291 | imgData.lookup = (SplashColorPtr)gmalloc(4 * n); | 2291 | imgData.lookup = (SplashColorPtr)gmallocn(n, 4); |
2292 | for (i = 0; i < n; ++i) { | 2292 | for (i = 0; i < n; ++i) { |
2293 | pix = (Guchar)i; | 2293 | pix = (Guchar)i; |
2294 | colorMap->getRGB(&pix, &rgb); | 2294 | colorMap->getRGB(&pix, &rgb); |
@@ -2300,7 +2300,7 @@ void SplashOutputDev::drawMaskedImage(GfxState *state, Object *ref, | |||
2300 | break; | 2300 | break; |
2301 | #if SPLASH_CMYK | 2301 | #if SPLASH_CMYK |
2302 | case splashModeCMYK8: | 2302 | case splashModeCMYK8: |
2303 | imgData.lookup = (SplashColorPtr)gmalloc(4 * n); | 2303 | imgData.lookup = (SplashColorPtr)gmallocn(n, 4); |
2304 | for (i = 0; i < n; ++i) { | 2304 | for (i = 0; i < n; ++i) { |
2305 | pix = (Guchar)i; | 2305 | pix = (Guchar)i; |
2306 | colorMap->getCMYK(&pix, &cmyk); | 2306 | colorMap->getCMYK(&pix, &cmyk); |
@@ -2421,7 +2421,7 @@ void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, | |||
2421 | break; | 2421 | break; |
2422 | case splashModeRGB8: | 2422 | case splashModeRGB8: |
2423 | case splashModeBGR8: | 2423 | case splashModeBGR8: |
2424 | imgData.lookup = (SplashColorPtr)gmalloc(3 * n); | 2424 | imgData.lookup = (SplashColorPtr)gmallocn(n, 3); |
2425 | for (i = 0; i < n; ++i) { | 2425 | for (i = 0; i < n; ++i) { |
2426 | pix = (Guchar)i; | 2426 | pix = (Guchar)i; |
2427 | colorMap->getRGB(&pix, &rgb); | 2427 | colorMap->getRGB(&pix, &rgb); |
@@ -2431,7 +2431,7 @@ void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, | |||
2431 | } | 2431 | } |
2432 | break; | 2432 | break; |
2433 | case splashModeXBGR8: | 2433 | case splashModeXBGR8: |
2434 | imgData.lookup = (SplashColorPtr)gmalloc(4 * n); | 2434 | imgData.lookup = (SplashColorPtr)gmallocn(n, 4); |
2435 | for (i = 0; i < n; ++i) { | 2435 | for (i = 0; i < n; ++i) { |
2436 | pix = (Guchar)i; | 2436 | pix = (Guchar)i; |
2437 | colorMap->getRGB(&pix, &rgb); | 2437 | colorMap->getRGB(&pix, &rgb); |
@@ -2443,7 +2443,7 @@ void SplashOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, | |||
2443 | break; | 2443 | break; |
2444 | #if SPLASH_CMYK | 2444 | #if SPLASH_CMYK |
2445 | case splashModeCMYK8: | 2445 | case splashModeCMYK8: |
2446 | imgData.lookup = (SplashColorPtr)gmalloc(4 * n); | 2446 | imgData.lookup = (SplashColorPtr)gmallocn(n, 4); |
2447 | for (i = 0; i < n; ++i) { | 2447 | for (i = 0; i < n; ++i) { |
2448 | pix = (Guchar)i; | 2448 | pix = (Guchar)i; |
2449 | colorMap->getCMYK(&pix, &cmyk); | 2449 | colorMap->getCMYK(&pix, &cmyk); |
diff --git a/splash/Splash.cc b/splash/Splash.cc index c93ef408..a1deb854 100644 --- a/splash/Splash.cc +++ b/splash/Splash.cc | |||
@@ -11,7 +11,7 @@ | |||
11 | // All changes made under the Poppler project to this file are licensed | 11 | // All changes made under the Poppler project to this file are licensed |
12 | // under GPL version 2 or later | 12 | // under GPL version 2 or later |
13 | // | 13 | // |
14 | // Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> | 14 | // Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> |
15 | // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> | 15 | // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> |
16 | // | 16 | // |
17 | // To see a description of the changes please see the Changelog file that | 17 | // To see a description of the changes please see the Changelog file that |
@@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, | |||
2001 | xq = w % scaledWidth; | 2001 | xq = w % scaledWidth; |
2002 | 2002 | ||
2003 | // allocate pixel buffer | 2003 | // allocate pixel buffer |
2004 | pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); | 2004 | pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); |
2005 | 2005 | ||
2006 | // initialize the pixel pipe | 2006 | // initialize the pixel pipe |
2007 | pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, | 2007 | pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, |
@@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, | |||
2301 | xq = w % scaledWidth; | 2301 | xq = w % scaledWidth; |
2302 | 2302 | ||
2303 | // allocate pixel buffers | 2303 | // allocate pixel buffers |
2304 | colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); | 2304 | colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); |
2305 | if (srcAlpha) { | 2305 | if (srcAlpha) { |
2306 | alphaBuf = (Guchar *)gmalloc((yp + 1) * w); | 2306 | alphaBuf = (Guchar *)gmallocn((yp + 1), w); |
2307 | } else { | 2307 | } else { |
2308 | alphaBuf = NULL; | 2308 | alphaBuf = NULL; |
2309 | } | 2309 | } |
diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc index 97d622cf..6cf2aea9 100644 --- a/splash/SplashBitmap.cc +++ b/splash/SplashBitmap.cc | |||
@@ -11,7 +11,7 @@ | |||
11 | // All changes made under the Poppler project to this file are licensed | 11 | // All changes made under the Poppler project to this file are licensed |
12 | // under GPL version 2 or later | 12 | // under GPL version 2 or later |
13 | // | 13 | // |
14 | // Copyright (C) 2006 Albert Astals Cid <aacid@kde.org> | 14 | // Copyright (C) 2006, 2009 Albert Astals Cid <aacid@kde.org> |
15 | // Copyright (C) 2007 Ilmari Heikkinen <ilmari.heikkinen@gmail.com> | 15 | // Copyright (C) 2007 Ilmari Heikkinen <ilmari.heikkinen@gmail.com> |
16 | // | 16 | // |
17 | // To see a description of the changes please see the Changelog file that | 17 | // To see a description of the changes please see the Changelog file that |
@@ -62,13 +62,13 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad, | |||
62 | } | 62 | } |
63 | rowSize += rowPad - 1; | 63 | rowSize += rowPad - 1; |
64 | rowSize -= rowSize % rowPad; | 64 | rowSize -= rowSize % rowPad; |
65 | data = (SplashColorPtr)gmalloc(rowSize * height); | 65 | data = (SplashColorPtr)gmallocn(rowSize, height); |
66 | if (!topDown) { | 66 | if (!topDown) { |
67 | data += (height - 1) * rowSize; | 67 | data += (height - 1) * rowSize; |
68 | rowSize = -rowSize; | 68 | rowSize = -rowSize; |
69 | } | 69 | } |
70 | if (alphaA) { | 70 | if (alphaA) { |
71 | alpha = (Guchar *)gmalloc(width * height); | 71 | alpha = (Guchar *)gmallocn(width, height); |
72 | } else { | 72 | } else { |
73 | alpha = NULL; | 73 | alpha = NULL; |
74 | } | 74 | } |
diff --git a/splash/SplashFTFont.cc b/splash/SplashFTFont.cc index 0039feb6..c3b298af 100644 --- a/splash/SplashFTFont.cc +++ b/splash/SplashFTFont.cc | |||
@@ -243,7 +243,7 @@ GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac, | |||
243 | } else { | 243 | } else { |
244 | rowSize = (bitmap->w + 7) >> 3; | 244 | rowSize = (bitmap->w + 7) >> 3; |
245 | } | 245 | } |
246 | bitmap->data = (Guchar *)gmalloc(rowSize * bitmap->h); | 246 | bitmap->data = (Guchar *)gmallocn(rowSize, bitmap->h); |
247 | bitmap->freeData = gTrue; | 247 | bitmap->freeData = gTrue; |
248 | for (i = 0, p = bitmap->data, q = slot->bitmap.buffer; | 248 | for (i = 0, p = bitmap->data, q = slot->bitmap.buffer; |
249 | i < bitmap->h; | 249 | i < bitmap->h; |