From 068a3eb5175b5aa843e322538a86a9d32bc0c595 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Fri, 6 Jan 2017 00:56:52 -0300 Subject: [PATCH] Fixed bad memory access in utf8ToUnicode class --- src/actions/transformations/utf8_to_unicode.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/actions/transformations/utf8_to_unicode.cc b/src/actions/transformations/utf8_to_unicode.cc index 8a9b2cb8..860b8ed8 100644 --- a/src/actions/transformations/utf8_to_unicode.cc +++ b/src/actions/transformations/utf8_to_unicode.cc @@ -92,9 +92,12 @@ char *Utf8ToUnicode::inplace(unsigned char *input, /* single byte unicode (7 bit ASCII equivilent) has no validation */ count++; if (count <= len) { - if (c == 0) - *data = utils::string::x2c(&c); - else + if (c == 0 && input_len > i + 1) { + unsigned char z[2]; + z[0] = *utf; + z[1] = *(utf + 1); + *data = utils::string::x2c((unsigned char*) &z); + } else *data++ = c; } } else if ((c & 0xE0) == 0xC0) {