diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2016-05-04 08:35:16 +0200 |
---|---|---|
committer | Rémi Verschelde <remi@verschelde.fr> | 2016-05-04 08:35:16 +0200 |
commit | 6a4b62e72069f7c96f8b7cb9b7855da0bbd84b63 (patch) | |
tree | 7b08e38c537d1bc1aa8dca42e5d7618a1aca989d | |
parent | dd69aeceac3d1798d0869d8adfb44af883b5fb93 (diff) | |
parent | c824781e9808bf1edb6b3fd963dda32eda5bf7ab (diff) |
Merge pull request #4535 from sanikoyes/Pr-crash-dynamic-font
Fix crash in dynamic font
-rw-r--r-- | scene/resources/dynamic_font.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index b9fd67bc2f..19aa0e79cc 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -261,6 +261,8 @@ void DynamicFontAtSize::_update_char(CharType p_char) { if (tex_index==-1) { //could not find texture to fit, create one + tex_x = 0; + tex_y = 0; int texsize = MAX(size*8,256); if (mw>texsize) @@ -280,6 +282,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) { { //zero texture DVector<uint8_t>::Write w = tex.imgdata.write(); + ERR_FAIL_COND(texsize*texsize*2 > tex.imgdata.size()); for(int i=0;i<texsize*texsize*2;i++) { w[i]=0; } @@ -305,6 +308,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) { for(int j=0;j<w;j++) { int ofs = ( (i+tex_y+rect_margin)*tex.texture_size+j+tex_x+rect_margin)*2; + ERR_FAIL_COND(ofs >= tex.imgdata.size()); wr[ofs+0]=255; //grayscale as 1 wr[ofs+1]=cpbitmap[i*w+j]; //alpha as 0 } |