]>
git.proxmox.com Git - pmg-log-tracker.git/commitdiff
projects
/
pmg-log-tracker.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
18c8f6b
)
parse_number: prevent panic on empty input
author
Fabian Grünbichler
<f.gruenbichler@proxmox.com>
Wed, 10 Jun 2020 13:22:53 +0000
(15:22 +0200)
committer
Thomas Lamprecht
<t.lamprecht@proxmox.com>
Wed, 17 Jun 2020 07:25:27 +0000
(09:25 +0200)
if data is empty or the caller requested 0 digits, we can return early.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/main.rs
patch
|
blob
|
blame
|
history
diff --git
a/src/main.rs
b/src/main.rs
index 94a62479834c4a7ecb0d9d77fd6062794d6181bc..613cecd36d57dc92267baeab2dfee8eab73d2a8d 100644
(file)
--- a/
src/main.rs
+++ b/
src/main.rs
@@
-2187,6
+2187,9
@@
fn parse_qid(data: &[u8], max: usize) -> Option<(&[u8], &[u8])> {
/// Parse a number. Returns a tuple of (parsed_number, remaining_text) or None.
fn parse_number(data: &[u8], max_digits: usize) -> Option<(usize, &[u8])> {
let max = max_digits.min(data.len());
+ if max == 0 {
+ return None;
+ }
match data.iter().take(max).position(|b| !b.is_ascii_digit()) {
Some(n) if n == 0 => None,