aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorHans Wennborg <hans@chromium.org>2016-10-27 15:49:06 -0700
committerMike Frysinger <vapier@chromium.org>2016-10-27 23:27:56 +0000
commit26ed3386af6d03de20510b0132cc37c4a10d9b97 (patch)
treeedf721aadcad44f725b8b796a77c5058ce750516 /src/common
parentGenerate reason for bad function table exception (diff)
downloadbreakpad-26ed3386af6d03de20510b0132cc37c4a10d9b97.tar.xz
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 <vapier@chromium.org>
Diffstat (limited to 'src/common')
-rw-r--r--src/common/string_conversion.cc6
1 files 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<uint16_t> *out) {
int UTF8ToUTF16Char(const char *in, int in_length, uint16_t out[2]) {
const UTF8 *source_ptr = reinterpret_cast<const UTF8 *>(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<const UTF32 *>(&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,