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

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: Change real_objnum to parser_objnum, check StrToInt overflow 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 T num = 0;
20 T num_new = 0;
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 = num * 10 + (*str) - '0';
26 if (num_new < 0) {
27 break;
Bo Xu 2014/09/19 21:48:19 Now check when the string is too long and overflow
Tom Sepez 2014/09/19 22:15:38 This can't work, either T is a signed type in whic
Bo Xu 2014/09/19 22:28:15 Done.
28 }
29 num = num_new;
25 str ++; 30 str ++;
26 } 31 }
27 return neg ? -num : num; 32 return neg ? -num : num;
28 } 33 }
29 template <typename T, typename STR_T> 34 template <typename T, typename STR_T>
30 STR_T FXSYS_IntToStr(T value, STR_T string, int radix) 35 STR_T FXSYS_IntToStr(T value, STR_T string, int radix)
31 { 36 {
32 int i = 0; 37 int i = 0;
33 if (value < 0) { 38 if (value < 0) {
34 string[i++] = '-'; 39 string[i++] = '-';
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 buf[wlen] = bstr[i]; 228 buf[wlen] = bstr[i];
224 } 229 }
225 wlen ++; 230 wlen ++;
226 } 231 }
227 return wlen; 232 return wlen;
228 } 233 }
229 #ifdef __cplusplus 234 #ifdef __cplusplus
230 } 235 }
231 #endif 236 #endif
232 #endif 237 #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