about summary refs log tree commit diff
path: root/src/libcore/num
diff options
context:
space:
mode:
authorRobin Kruppe <robin.kruppe@gmail.com>2015-10-14 19:27:49 +0200
committerRobin Kruppe <robin.kruppe@gmail.com>2015-10-14 19:55:59 +0200
commit71dcd7f70c084ea4f8e7788b617c9c2ea786e6b7 (patch)
tree84b50f4a26af5f7b5a9c6e66591ae8db89938aca /src/libcore/num
parente3cd87241898cd88e4348e9c6142a03d8909c4e0 (diff)
downloadrust-71dcd7f70c084ea4f8e7788b617c9c2ea786e6b7.tar.gz
rust-71dcd7f70c084ea4f8e7788b617c9c2ea786e6b7.zip
Reject "+" and "-" when parsing floats.
Fixes #29042
Diffstat (limited to 'src/libcore/num')
-rw-r--r--src/libcore/num/dec2flt/parse.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libcore/num/dec2flt/parse.rs b/src/libcore/num/dec2flt/parse.rs
index 58e2a6e9bba..414bcc874ea 100644
--- a/src/libcore/num/dec2flt/parse.rs
+++ b/src/libcore/num/dec2flt/parse.rs
@@ -59,7 +59,12 @@ pub fn parse_decimal(s: &str) -> ParseResult {
     let s = s.as_bytes();
     let (integral, s) = eat_digits(s);
     match s.first() {
-        None => Valid(Decimal::new(integral, b"", 0)),
+        None => {
+            if integral.is_empty() {
+                return Invalid; // No digits at all
+            }
+            Valid(Decimal::new(integral, b"", 0))
+        }
         Some(&b'e') | Some(&b'E') => {
             if integral.is_empty() {
                 return Invalid; // No digits before 'e'