소스 검색

Fix ValidateDateTime: check day instead month

Found with PVS-Studio static analyser, see 
https://www.viva64.com/en/b/0550/
Anton Fedorov 7 년 전
부모
커밋
473c5cff76
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      src/google/protobuf/stubs/time.cc

+ 2 - 2
src/google/protobuf/stubs/time.cc

@@ -80,9 +80,9 @@ bool ValidateDateTime(const DateTime& time) {
     return false;
     return false;
   }
   }
   if (time.month == 2 && IsLeapYear(time.year)) {
   if (time.month == 2 && IsLeapYear(time.year)) {
-    return time.month <= kDaysInMonth[time.month] + 1;
+    return time.day <= kDaysInMonth[time.month] + 1;
   } else {
   } else {
-    return time.month <= kDaysInMonth[time.month];
+    return time.day <= kDaysInMonth[time.month];
   }
   }
 }
 }