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

Side by Side Diff: base/third_party/symbolize/symbolize.cc

Issue 1187063003: Fix -INT_MIN integer overflow in itoa_r(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 | « base/debug/stack_trace_posix.cc ('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 (c) 2006, Google Inc. 1 // Copyright (c) 2006, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 buf[0] = '\000'; 644 buf[0] = '\000';
645 return NULL; 645 return NULL;
646 } 646 }
647 647
648 char *start = buf; 648 char *start = buf;
649 649
650 uintptr_t j = i; 650 uintptr_t j = i;
651 651
652 // Handle negative numbers (only for base 10). 652 // Handle negative numbers (only for base 10).
653 if (i < 0 && base == 10) { 653 if (i < 0 && base == 10) {
654 j = -i; 654 // This does "j = -i" while avoiding integer overflow.
655 j = static_cast<uintptr_t>(-(i + 1)) + 1;
655 656
656 // Make sure we can write the '-' character. 657 // Make sure we can write the '-' character.
657 if (++n > sz) { 658 if (++n > sz) {
658 buf[0] = '\000'; 659 buf[0] = '\000';
659 return NULL; 660 return NULL;
660 } 661 }
661 *start++ = '-'; 662 *start++ = '-';
662 } 663 }
663 664
664 // Loop until we have converted the entire number. Output at least one 665 // Loop until we have converted the entire number. Output at least one
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 840
840 // TODO: Support other environments. 841 // TODO: Support other environments.
841 bool Symbolize(void *pc, char *out, int out_size) { 842 bool Symbolize(void *pc, char *out, int out_size) {
842 assert(0); 843 assert(0);
843 return false; 844 return false;
844 } 845 }
845 846
846 _END_GOOGLE_NAMESPACE_ 847 _END_GOOGLE_NAMESPACE_
847 848
848 #endif 849 #endif
OLDNEW
« no previous file with comments | « base/debug/stack_trace_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698