diff options
author | Alex Crichton <alex@alexcrichton.com> | 2017-05-30 19:35:42 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-30 19:35:42 -0500 |
commit | dfe67d6c60ab96e80d02747f60d0635acc67f718 (patch) | |
tree | 4710364895c56e9fa52a88fa3f20880b7891e664 /src | |
parent | 7aa2594fb0ccd528087a492d1497f3af580bdb54 (diff) | |
parent | f98d6ccd70850708ca9d7fc98c561556148b397d (diff) | |
download | milf-rs-dfe67d6c60ab96e80d02747f60d0635acc67f718.tar.gz milf-rs-dfe67d6c60ab96e80d02747f60d0635acc67f718.zip |
Merge pull request #182 from alanhdu/master
Fix some fuzzing bugs
Diffstat (limited to 'src')
-rw-r--r-- | src/datetime.rs | 10 | ||||
-rw-r--r-- | src/ser.rs | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/datetime.rs b/src/datetime.rs index 7917cad..f39d9fa 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -55,7 +55,7 @@ struct Time { hour: u8, minute: u8, second: u8, - secfract: Option<f64>, + secfract: f64, } #[derive(PartialEq, Clone)] @@ -97,8 +97,8 @@ impl fmt::Display for Date { impl fmt::Display for Time { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:02}:{:02}:{:02}", self.hour, self.minute, self.second)?; - if let Some(i) = self.secfract { - let s = format!("{}", i); + if self.secfract != 0.0 { + let s = format!("{}", self.secfract); write!(f, "{}", s.trim_left_matches("0"))?; } Ok(()) @@ -219,11 +219,11 @@ impl FromStr for Datetime { } chars = whole[end..].chars(); match format!("0.{}", &whole[..end]).parse() { - Ok(f) => Some(f), + Ok(f) => f, Err(_) => return Err(DatetimeParseError { _private: () }), } } else { - None + 0.0 }; let time = Time { @@ -290,7 +290,7 @@ impl<'a> Serializer<'a> { '\u{22}' => drop(write!(self.dst, "\\\"")), '\u{5c}' => drop(write!(self.dst, "\\\\")), c if c < '\u{1f}' => { - drop(write!(self.dst, "\\u{:04}", ch as u32)) + drop(write!(self.dst, "\\u{:04X}", ch as u32)) } ch => drop(write!(self.dst, "{}", ch)), } |