Skip to content

Commit

Permalink
Some paranoid checks in PPGeDraw. Might help the crash seen in #13047.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jun 28, 2020
1 parent 807fcf8 commit 63ead85
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Core/Util/PPGeDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ static PPGeTextDrawerImage PPGeGetTextImage(const char *text, PPGeAlign align, f
}

PPGeTextDrawerCacheKey key{ text, tdalign, maxWidth / scale };
PPGeTextDrawerImage im;
PPGeTextDrawerImage im{};

auto cacheItem = textDrawerImages.find(key);
if (cacheItem != textDrawerImages.end()) {
Expand Down Expand Up @@ -843,6 +843,10 @@ static PPGeTextDrawerImage PPGeGetTextImage(const char *text, PPGeAlign align, f
}

static void PPGeDrawTextImage(PPGeTextDrawerImage im, float x, float y, PPGeAlign align, float scale, u32 color) {
if (!im.ptr) {
return;
}

int bufw = ((im.entry.bmWidth + 31) / 32) * 32;
int wp2 = GetPow2(im.entry.bmWidth);
int hp2 = GetPow2(im.entry.bmHeight);
Expand Down Expand Up @@ -874,6 +878,10 @@ static void PPGeDrawTextImage(PPGeTextDrawerImage im, float x, float y, PPGeAlig
}

void PPGeDrawText(const char *text, float x, float y, PPGeAlign align, float scale, u32 color) {
if (!text || !strlen(text)) {
return;
}

if (HasTextDrawer()) {
PPGeTextDrawerImage im = PPGeGetTextImage(text, align, scale, 480.0f - x, false);
PPGeDrawTextImage(im, x, y, align, scale, color);
Expand Down

1 comment on commit 63ead85

@hrydgard
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh, I mean #13057

Please sign in to comment.