Skip to content

Commit

Permalink
Check for invalid cast
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Feb 27, 2024
1 parent bbdc332 commit a6c0c64
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/naive/datetime/serde.rs
Expand Up @@ -972,7 +972,11 @@ pub mod ts_seconds {
where
E: de::Error,
{
NaiveDateTime::from_timestamp_opt(value as i64, 0).ok_or_else(|| invalid_ts(value))
if value > i64::MAX as u64 {
Err(invalid_ts(value))
} else {
NaiveDateTime::from_timestamp_opt(value as i64, 0).ok_or_else(|| invalid_ts(value))
}
}
}
}
Expand Down

0 comments on commit a6c0c64

Please sign in to comment.