Ver código fonte

fix ubsan warning

Signed-off-by: Asra Ali <asraa@google.com>
Asra Ali 6 anos atrás
pai
commit
de3e728c69
1 arquivos alterados com 4 adições e 2 exclusões
  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) {
-  uint32 u = i;
+  uint32 u = 0;
   if (i < 0) {
     *buffer++ = '-';
-    u = -i;
+    u -= i;
+  } else {
+    u = i;
   }
   return FastUInt32ToBufferLeft(u, buffer);
 }