[poppler] splash/Splash.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Mon Jul 25 14:43:41 PDT 2011
splash/Splash.cc | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
New commits:
commit 2c1b25ef2592367f4c18e204ab5d102f15cf272f
Author: William Bader <williambader at hotmail.com>
Date: Mon Jul 25 23:43:27 2011 +0200
Fix a bad memory access
When not using antialias and the character starts to the left/top of the image
Bug 37189
diff --git a/splash/Splash.cc b/splash/Splash.cc
index cfc6ba2..fe7c001 100644
--- a/splash/Splash.cc
+++ b/splash/Splash.cc
@@ -1772,17 +1772,23 @@ void Splash::fillGlyph2(int x0, int y0, SplashGlyphBitmap *glyph, GBool noClip)
int yStart = y0 - glyph->y;
int xxLimit = glyph->w;
int yyLimit = glyph->h;
+ int xShift = 0;
if (yStart < 0)
{
- p += glyph->w * -yStart; // move p to the beginning of the first painted row
+ p += (glyph->aa ? glyph->w : splashCeil(glyph->w / 8.0)) * -yStart; // move p to the beginning of the first painted row
yyLimit += yStart;
yStart = 0;
}
if (xStart < 0)
{
- p += -xStart; // move p to the first painted pixel
+ if (glyph->aa) {
+ p += -xStart;
+ } else {
+ p += (-xStart) / 8;
+ xShift = (-xStart) % 8;
+ }
xxLimit += xStart;
xStart = 0;
}
@@ -1817,7 +1823,7 @@ void Splash::fillGlyph2(int x0, int y0, SplashGlyphBitmap *glyph, GBool noClip)
for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) {
pipeSetXY(&pipe, xStart, y1);
for (xx = 0, x1 = xStart; xx < xxLimit; xx += 8) {
- alpha0 = p[xx / 8];
+ alpha0 = (xShift > 0 ? (p[xx / 8] << xShift) | (p[xx / 8 + 1] >> (8 - xShift)) : p[xx / 8]);
for (xx1 = 0; xx1 < 8 && xx + xx1 < xxLimit; ++xx1, ++x1) {
if (alpha0 & 0x80) {
pipeRun(&pipe);
@@ -1863,7 +1869,7 @@ void Splash::fillGlyph2(int x0, int y0, SplashGlyphBitmap *glyph, GBool noClip)
for (yy = 0, y1 = yStart; yy < yyLimit; ++yy, ++y1) {
pipeSetXY(&pipe, xStart, y1);
for (xx = 0, x1 = xStart; xx < xxLimit; xx += 8) {
- alpha0 = p[xx / 8];
+ alpha0 = (xShift > 0 ? (p[xx / 8] << xShift) | (p[xx / 8 + 1] >> (8 - xShift)) : p[xx / 8]);
for (xx1 = 0; xx1 < 8 && xx + xx1 < xxLimit; ++xx1, ++x1) {
if (state->clip->test(x1, y1)) {
if (alpha0 & 0x80) {
More information about the poppler
mailing list