[libcxx-commits] [PATCH] D81477: [libc++] Avoid UB in year_month_day_last::day() for incorrect months

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 9 10:59:27 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG1f48f8f6e289: [libc++] Avoid UB in year_month_day_last::day() for incorrect months (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81477/new/

https://reviews.llvm.org/D81477

Files:
  libcxx/include/chrono


Index: libcxx/include/chrono
===================================================================
--- libcxx/include/chrono
+++ libcxx/include/chrono
@@ -2454,7 +2454,7 @@
         chrono::day(31), chrono::day(31), chrono::day(30),
         chrono::day(31), chrono::day(30), chrono::day(31)
     };
-    return month() != February || !__y.is_leap() ?
+    return (month() != February || !__y.is_leap()) && month().ok() ?
         __d[static_cast<unsigned>(month()) - 1] : chrono::day{29};
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81477.269605.patch
Type: text/x-patch
Size: 493 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200609/bdd94fe9/attachment.bin>


More information about the libcxx-commits mailing list