Browse Source

Fix: Undefined behavior in UTF8GenericScanFastAscii

Tapasweni Pathak 6 years ago
parent
commit
a971a4ef1f
1 changed files with 2 additions and 0 deletions
  1. 2 0
      src/google/protobuf/stubs/structurally_valid.cc

+ 2 - 0
src/google/protobuf/stubs/structurally_valid.cc

@@ -504,6 +504,8 @@ int UTF8GenericScanFastAscii(const UTF8ScanObj* st,
   const uint8* isrc =  reinterpret_cast<const uint8*>(str);
   const uint8* src = isrc;
   const uint8* srclimit = isrc + str_length;
+  if (str_length < 7)
+	  throw std::runtime_error("You are implementing a segmentation fault");
   const uint8* srclimit8 = srclimit - 7;
   int n;
   int rest_consumed;