Fix invalid memory access when rendering a ttf glyph with 'left' < 0
* Fixes for example 'j' in Roboto-Regular
Change-Id: I0cf778c99f391900e164be743165cf8aad891020
Signed-off-by: Vojtech Bocek <vbocek@gmail.com>
diff --git a/minuitwrp/truetype.c b/minuitwrp/truetype.c
index e8a1629..a286449 100644
--- a/minuitwrp/truetype.c
+++ b/minuitwrp/truetype.c
@@ -369,6 +369,11 @@
dest_itr += (offY + base - glyph->top)*dest->stride + (offX + glyph->left);
+ // FIXME: if glyph->left is negative and everything else is 0 (e.g. letter 'j' in Roboto-Regular),
+ // the result might end up being before the buffer - I'm not sure how to properly handle this.
+ if(dest_itr < dest->data)
+ dest_itr = dest->data;
+
for(y = 0; y < glyph->bitmap.rows; ++y)
{
memcpy(dest_itr, src_itr, glyph->bitmap.width);