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

Side by Side Diff: core/src/fxcrt/fx_basic_gcc.cpp

Issue 524443002: Fix a bug when assign the generation number of indirect objects (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Use safe math Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../include/fxcrt/fx_ext.h" 7 #include "../../include/fxcrt/fx_ext.h"
8 template <class T, class STR_T> 8 template <class T, class STR_T>
9 T FXSYS_StrToInt(STR_T str) 9 T FXSYS_StrToInt(STR_T str)
10 { 10 {
11 FX_BOOL neg = FALSE; 11 FX_BOOL neg = FALSE;
12 if (str == NULL) { 12 if (str == NULL) {
13 return 0; 13 return 0;
14 } 14 }
15 if (*str == '-') { 15 if (*str == '-') {
16 neg = TRUE; 16 neg = TRUE;
17 str ++; 17 str ++;
18 } 18 }
19 T num = 0; 19 base::CheckedNumeric<T> num = 0;
Tom Sepez 2014/09/19 22:35:07 num doesn't need to be checked.
20 base::CheckedNumeric<T> num_new = num;
Tom Sepez 2014/09/19 22:35:07 maybe this moves to right before line 25, and its
20 while (*str) { 21 while (*str) {
21 if ((*str) < '0' || (*str) > '9') { 22 if ((*str) < '0' || (*str) > '9') {
22 break; 23 break;
23 } 24 }
24 num = num * 10 + (*str) - '0'; 25 num_new *= 10;
26 num_new += (*str) - '0';
27 if (!num_new.IsValid()) {
28 break;
29 }
30 num = num_new;
Tom Sepez 2014/09/19 22:35:07 num = new_num.ValueOrDie();
25 str ++; 31 str ++;
26 } 32 }
27 return neg ? -num : num; 33 return neg ? -num.ValueOrDie() : num.ValueOrDie();
28 } 34 }
29 template <typename T, typename STR_T> 35 template <typename T, typename STR_T>
30 STR_T FXSYS_IntToStr(T value, STR_T string, int radix) 36 STR_T FXSYS_IntToStr(T value, STR_T string, int radix)
31 { 37 {
32 int i = 0; 38 int i = 0;
33 if (value < 0) { 39 if (value < 0) {
34 string[i++] = '-'; 40 string[i++] = '-';
35 value = -value; 41 value = -value;
36 } else if (value == 0) { 42 } else if (value == 0) {
37 string[0] = '0'; 43 string[0] = '0';
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 buf[wlen] = bstr[i]; 229 buf[wlen] = bstr[i];
224 } 230 }
225 wlen ++; 231 wlen ++;
226 } 232 }
227 return wlen; 233 return wlen;
228 } 234 }
229 #ifdef __cplusplus 235 #ifdef __cplusplus
230 } 236 }
231 #endif 237 #endif
232 #endif 238 #endif
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698