Selaa lähdekoodia

fix ubsan warning

Signed-off-by: Asra Ali <asraa@google.com>
Asra Ali 6 vuotta sitten
vanhempi
commit
de3e728c69
1 muutettua tiedostoa jossa 4 lisäystä ja 2 poistoa
  1. 4 2
      src/google/protobuf/stubs/strutil.cc

+ 4 - 2
src/google/protobuf/stubs/strutil.cc

@@ -1065,10 +1065,12 @@ done:
 }
 }
 
 
 char* FastInt32ToBufferLeft(int32 i, char* buffer) {
 char* FastInt32ToBufferLeft(int32 i, char* buffer) {
-  uint32 u = i;
+  uint32 u = 0;
   if (i < 0) {
   if (i < 0) {
     *buffer++ = '-';
     *buffer++ = '-';
-    u = -i;
+    u -= i;
+  } else {
+    u = i;
   }
   }
   return FastUInt32ToBufferLeft(u, buffer);
   return FastUInt32ToBufferLeft(u, buffer);
 }
 }