Skip to content

Commit

Permalink
[date] Fix uninitialized values (#23710)
Browse files Browse the repository at this point in the history
* [date] Fix uninitialized values

* update version

* add notes for patch

* update version
  • Loading branch information
JonLiu1993 authored Apr 5, 2022
1 parent bfda043 commit 1143d75
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
40 changes: 40 additions & 0 deletions ports/date/fix-uninitialized-values.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/include/date/date.h b/include/date/date.h
index 9c6f335..3967d6b 100644
--- a/include/date/date.h
+++ b/include/date/date.h
@@ -6767,7 +6767,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
int tH;
int tM;
- long double S;
+ long double S{};
read(is, ru{tH, 1, 2}, CharT{':'}, ru{tM, 1, 2},
CharT{':'}, rld{S, 1, w});
checked_set(H, tH, not_a_hour, is);
@@ -7202,7 +7202,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
// "%I:%M:%S %p"
using dfs = detail::decimal_format_seconds<Duration>;
CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
- long double S;
+ long double S{};
int tI = not_a_hour_12_value;
int tM = not_a_minute;
read(is, ru{tI, 1, 2}, CharT{':'}, ru{tM, 1, 2},
@@ -7258,7 +7258,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
{
using dfs = detail::decimal_format_seconds<Duration>;
CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
- long double S;
+ long double S{};
read(is, rld{S, 1, width == -1 ? w : static_cast<unsigned>(width)});
checked_set(s, round_i<Duration>(duration<long double>{S}),
not_a_second, is);
@@ -7292,7 +7292,7 @@ from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
int tH = not_a_hour;
int tM = not_a_minute;
- long double S;
+ long double S{};
read(is, ru{tH, 1, 2}, CharT{':'}, ru{tM, 1, 2},
CharT{':'}, rld{S, 1, w});
checked_set(H, tH, not_a_hour, is);
1 change: 1 addition & 0 deletions ports/date/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ vcpkg_from_github(
PATCHES
0001-fix-uwp.patch
0002-fix-cmake-3.14.patch
fix-uninitialized-values.patch #Update the new version please remove this patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
Expand Down
2 changes: 1 addition & 1 deletion ports/date/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "date",
"version": "3.0.1",
"port-version": 1,
"port-version": 2,
"description": "A date and time library based on the C++17 <chrono> header",
"homepage": "https://github.com/HowardHinnant/date",
"dependencies": [
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@
},
"date": {
"baseline": "3.0.1",
"port-version": 1
"port-version": 2
},
"dav1d": {
"baseline": "0.8.2",
Expand Down
5 changes: 5 additions & 0 deletions versions/d-/date.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "14d5c6822908ad2fd1d700cca2067ae4b8ef4404",
"version": "3.0.1",
"port-version": 2
},
{
"git-tree": "e281c60aee492a2be56e78ce6a53cb5db927b1dc",
"version": "3.0.1",
Expand Down

0 comments on commit 1143d75

Please sign in to comment.