diff options
author | Andreas Kling <andreas.kling@nokia.com> | 2010-06-25 08:37:56 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2010-06-25 10:13:29 +0200 |
commit | 4b88f595ab62b7c5f703a286c4f5f13f8784a936 (patch) | |
tree | d509dccc47e2bbb0d6aefe203e800a1778a5a811 | |
parent | a80fd59e3b3b18116803a14e6369345933994236 (diff) |
Null-terminate output data in to_tis620()
This fixes a crash in thaiWordBreaks() detected a WebKit layout test.
Specifically, editing/selection/thai-word-at-document-end.html
Regressed with cce760d41f115fecd5b9b6b20b62883b10a9c204
Signed-off-by: Simon Hausmann <simon.hausmann@nokia.com>
-rw-r--r-- | src/harfbuzz-thai.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/harfbuzz-thai.c b/src/harfbuzz-thai.c index fc2bdbf..e153ba9 100644 --- a/src/harfbuzz-thai.c +++ b/src/harfbuzz-thai.c @@ -53,6 +53,8 @@ static void to_tis620(const HB_UChar16 *string, hb_uint32 len, const char *cstr) else result[i] = '?'; } + + result[len] = 0; } static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttributes *attributes) @@ -70,8 +72,8 @@ static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttri if (!th_brk) return; - if (len > 128) - cstr = (char *)malloc(len*sizeof(char)); + if (len >= 128) + cstr = (char *)malloc(len*sizeof(char) + 1); to_tis620(string, len, cstr); @@ -96,7 +98,7 @@ static void thaiWordBreaks(const HB_UChar16 *string, hb_uint32 len, HB_CharAttri if (break_positions != brp) free(break_positions); - if (len > 128) + if (len >= 128) free(cstr); } |