Sfoglia il codice sorgente

Merge pull request #2496 from xyzzyz/fix-overflow

Fix integer overflow in FastUInt32ToBufferLeft
Feng Xiao 8 anni fa
parent
commit
f983302ca7
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  1. 1 1
      src/google/protobuf/stubs/strutil.cc

+ 1 - 1
src/google/protobuf/stubs/strutil.cc

@@ -981,7 +981,7 @@ static const char two_ASCII_digits[100][2] = {
 };
 };
 
 
 char* FastUInt32ToBufferLeft(uint32 u, char* buffer) {
 char* FastUInt32ToBufferLeft(uint32 u, char* buffer) {
-  int digits;
+  uint32 digits;
   const char *ASCII_digits = NULL;
   const char *ASCII_digits = NULL;
   // The idea of this implementation is to trim the number of divides to as few
   // The idea of this implementation is to trim the number of divides to as few
   // as possible by using multiplication and subtraction rather than mod (%),
   // as possible by using multiplication and subtraction rather than mod (%),