summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2009-04-11 00:23:04 +0200
committerAlbert Astals Cid <aacid@kde.org>2009-04-11 00:23:04 +0200
commit7b2d314a61fd0e12f47c62996cb49ec0d1ba747a (patch)
tree064d114c633e1d698211a85026580aacdc12309a
parent0131f0a01cba8691d10a18de1137a4744988b346 (diff)
Be paranoid, use gmallocn or gmallocn3 in all gmalloc with *
-rw-r--r--poppler/ArthurOutputDev.cc4
-rw-r--r--poppler/CairoOutputDev.cc14
-rw-r--r--poppler/GfxState.cc8
-rw-r--r--poppler/JBIG2Stream.cc4
-rw-r--r--poppler/PSOutputDev.cc6
-rw-r--r--poppler/SplashOutputDev.cc20
6 files changed, 28 insertions, 28 deletions
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/JBIG2Stream.cc b/poppler/JBIG2Stream.cc
index 938927e3..31c829a0 100644
--- a/poppler/JBIG2Stream.cc
+++ b/poppler/JBIG2Stream.cc
@@ -707,7 +707,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA):
707 return; 707 return;
708 } 708 }
709 // need to allocate one extra guard byte for use in combine() 709 // need to allocate one extra guard byte for use in combine()
710 data = (Guchar *)gmalloc(h * line + 1); 710 data = (Guchar *)gmallocn(h, line + 1);
711 data[h * line] = 0; 711 data[h * line] = 0;
712} 712}
713 713
@@ -724,7 +724,7 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap):
724 return; 724 return;
725 } 725 }
726 // need to allocate one extra guard byte for use in combine() 726 // need to allocate one extra guard byte for use in combine()
727 data = (Guchar *)gmalloc(h * line + 1); 727 data = (Guchar *)gmallocn(h, line + 1);
728 memcpy(data, bitmap->data, h * line); 728 memcpy(data, bitmap->data, h * line);
729 data[h * line] = 0; 729 data[h * line] = 0;
730} 730}
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..1efe1f33 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, 3);
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);