Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1675)

Unified Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp

Issue 306923006: Use unsigned type for iteration to avoid int overflow. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: make max_chars unsigned too. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index c395283fc3a5d01619bf4bac87a14fc1391439d5..022d788c72d54d6efdc2d313d253741a2eb59b18 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -1,7 +1,7 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../../include/fpdfapi/fpdf_parser.h"
@@ -402,7 +402,7 @@ CFX_WideString PDF_DecodeText(FX_LPCBYTE src_data, FX_DWORD src_len, CFX_CharMap
CFX_WideString result;
if (src_len >= 2 && ((src_data[0] == 0xfe && src_data[1] == 0xff) || (src_data[0] == 0xff && src_data[1] == 0xfe))) {
FX_BOOL bBE = src_data[0] == 0xfe;
- int max_chars = (src_len - 2) / 2;
+ FX_DWORD max_chars = (src_len - 2) / 2;
if (!max_chars) {
return result;
}
@@ -412,7 +412,7 @@ CFX_WideString PDF_DecodeText(FX_LPCBYTE src_data, FX_DWORD src_len, CFX_CharMap
FX_LPWSTR dest_buf = result.GetBuffer(max_chars);
FX_LPCBYTE uni_str = src_data + 2;
int dest_pos = 0;
- for (int i = 0; i < max_chars * 2; i += 2) {
+ for (FX_DWORD i = 0; i < max_chars * 2; i += 2) {
FX_WORD unicode = bBE ? (uni_str[i] << 8 | uni_str[i + 1]) : (uni_str[i + 1] << 8 | uni_str[i]);
if (unicode == 0x1b) {
i += 2;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698