diff --git a/extern/ttconv/pprdrv_tt.cpp b/extern/ttconv/pprdrv_tt.cpp index b471e93743ce..58a0531e9169 100644 --- a/extern/ttconv/pprdrv_tt.cpp +++ b/extern/ttconv/pprdrv_tt.cpp @@ -137,7 +137,7 @@ BYTE *GetTable(struct TTFONT *font, const char *name) offset = getULONG( ptr + 8 ); length = getULONG( ptr + 12 ); - table = (BYTE*)calloc( sizeof(BYTE), length ); + table = (BYTE*)calloc( sizeof(BYTE), length + 2 ); try { @@ -160,6 +160,9 @@ BYTE *GetTable(struct TTFONT *font, const char *name) free(table); throw; } + /* Always NUL-terminate; add two in case of UTF16 strings. */ + table[length] = '\0'; + table[length + 1] = '\0'; return table; } diff --git a/src/ft2font.cpp b/src/ft2font.cpp index f178379366a5..2149cb037ab7 100644 --- a/src/ft2font.cpp +++ b/src/ft2font.cpp @@ -601,9 +601,7 @@ void FT2Font::set_text( FT_Bool use_kerning = FT_HAS_KERNING(face); FT_UInt previous = 0; - glyphs.resize(0); - pen.x = 0; - pen.y = 0; + clear(); bbox.xMin = bbox.yMin = 32000; bbox.xMax = bbox.yMax = -32000;