From 9eb39faf97fa4b5b7aa388a64a0c913b5e0f2914 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 13 Feb 2008 20:01:38 +0000 Subject: [PATCH] if we could not create the cache because it needed to be too big, try to use it later Fixes bug 157777 svn path=/branches/KDE/3.5/kdegraphics/kpdf/; revision=774669 --- xpdf/splash/SplashFont.cc | 48 +++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/xpdf/splash/SplashFont.cc b/xpdf/splash/SplashFont.cc index e4ab59c89..4a91d5e8f 100644 --- a/xpdf/splash/SplashFont.cc +++ b/xpdf/splash/SplashFont.cc @@ -167,27 +167,35 @@ GBool SplashFont::getGlyph(int c, int xFrac, int yFrac, size = ((bitmap2.w + 7) >> 3) * bitmap2.h; } p = NULL; // make gcc happy - for (j = 0; j < cacheAssoc; ++j) { - if ((cacheTags[i+j].mru & 0x7fffffff) == cacheAssoc - 1) { - cacheTags[i+j].mru = 0x80000000; - cacheTags[i+j].c = c; - cacheTags[i+j].xFrac = (short)xFrac; - cacheTags[i+j].yFrac = (short)yFrac; - cacheTags[i+j].x = bitmap2.x; - cacheTags[i+j].y = bitmap2.y; - cacheTags[i+j].w = bitmap2.w; - cacheTags[i+j].h = bitmap2.h; - p = cache + (i+j) * glyphSize; - memcpy(p, bitmap2.data, size); - } else { - ++cacheTags[i+j].mru; - } + if (cacheAssoc == 0) + { + // we had problems on the malloc of the cache, so ignore it + *bitmap = bitmap2; } - *bitmap = bitmap2; - bitmap->data = p; - bitmap->freeData = gFalse; - if (bitmap2.freeData) { - gfree(bitmap2.data); + else + { + for (j = 0; j < cacheAssoc; ++j) { + if ((cacheTags[i+j].mru & 0x7fffffff) == cacheAssoc - 1) { + cacheTags[i+j].mru = 0x80000000; + cacheTags[i+j].c = c; + cacheTags[i+j].xFrac = (short)xFrac; + cacheTags[i+j].yFrac = (short)yFrac; + cacheTags[i+j].x = bitmap2.x; + cacheTags[i+j].y = bitmap2.y; + cacheTags[i+j].w = bitmap2.w; + cacheTags[i+j].h = bitmap2.h; + p = cache + (i+j) * glyphSize; + memcpy(p, bitmap2.data, size); + } else { + ++cacheTags[i+j].mru; + } + } + *bitmap = bitmap2; + bitmap->data = p; + bitmap->freeData = gFalse; + if (bitmap2.freeData) { + gfree(bitmap2.data); + } } return gTrue; }