소스 검색

Fix: Undefined behavior in UTF8GenericScanFastAscii

Tapasweni Pathak 6 년 전
부모
커밋
a971a4ef1f
1개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  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;