From 26ed3386af6d03de20510b0132cc37c4a10d9b97 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Thu, 27 Oct 2016 15:49:06 -0700 Subject: [PATCH] Fix pointer arithmetic in UTF8ToUTF16Char Found by PVS-Studio! BUG=chromium:660198 Change-Id: I2605de2b1499f85c6e01d19e87e9eeb6af8486f3 Reviewed-on: https://chromium-review.googlesource.com/404552 Reviewed-by: Mike Frysinger --- src/common/string_conversion.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/string_conversion.cc b/src/common/string_conversion.cc index 9c0d623f..040d3e86 100644 --- a/src/common/string_conversion.cc +++ b/src/common/string_conversion.cc @@ -57,9 +57,9 @@ void UTF8ToUTF16(const char *in, vector *out) { int UTF8ToUTF16Char(const char *in, int in_length, uint16_t out[2]) { const UTF8 *source_ptr = reinterpret_cast(in); - const UTF8 *source_end_ptr = source_ptr + sizeof(char); + const UTF8 *source_end_ptr = source_ptr + 1; uint16_t *target_ptr = out; - uint16_t *target_end_ptr = target_ptr + 2 * sizeof(uint16_t); + uint16_t *target_end_ptr = target_ptr + 2; out[0] = out[1] = 0; // Process one character at a time @@ -103,7 +103,7 @@ void UTF32ToUTF16Char(wchar_t in, uint16_t out[2]) { const UTF32 *source_ptr = reinterpret_cast(&in); const UTF32 *source_end_ptr = source_ptr + 1; uint16_t *target_ptr = out; - uint16_t *target_end_ptr = target_ptr + 2 * sizeof(uint16_t); + uint16_t *target_end_ptr = target_ptr + 2; out[0] = out[1] = 0; ConversionResult result = ConvertUTF32toUTF16(&source_ptr, source_end_ptr, &target_ptr, target_end_ptr,