DrawArt: Fix bounds check (#3395)

The bounds checks were performed against the global screen dimensions
instead of the output buffer dimensions.

Also includes some minor cleanup of DrawArt.

Fixes #3388
This commit is contained in:
Gleb Mazovetskiy 2021-11-05 14:17:56 +00:00 committed by GitHub
commit 117695489b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 18 deletions

View file

@ -346,7 +346,7 @@ uint32_t DrawString(const Surface &out, string_view text, const Rectangle &rect,
characterPosition.x += rect.size.width - lineWidth;
int rightMargin = rect.position.x + rect.size.width;
int bottomMargin = rect.size.height != 0 ? rect.position.y + rect.size.height : out.h();
const int bottomMargin = rect.size.height != 0 ? std::min(rect.position.y + rect.size.height, out.h()) : out.h();
if (lineHeight == -1)
lineHeight = LineHeights[size];