aboutsummaryrefslogtreecommitdiff
path: root/src/lib/_uint.rs
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2011-04-27 11:45:53 -0700
committerPatrick Walton <[email protected]>2011-04-27 11:49:06 -0700
commit73044b3455b7586557eabbd249023d0a363401d0 (patch)
tree5bcf638357ed9fef32a0f99f2ff24c978cc1587b /src/lib/_uint.rs
parentPartly disable simplified-type glue optimization due to compile-time cost. (diff)
downloadrust-73044b3455b7586557eabbd249023d0a363401d0.tar.xz
rust-73044b3455b7586557eabbd249023d0a363401d0.zip
stdlib: Fix a crazy underflow bug in _uint.parse_buf. Oops.
Diffstat (limited to 'src/lib/_uint.rs')
-rw-r--r--src/lib/_uint.rs5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/lib/_uint.rs b/src/lib/_uint.rs
index f6686b5d..ce01dabf 100644
--- a/src/lib/_uint.rs
+++ b/src/lib/_uint.rs
@@ -37,12 +37,11 @@ fn parse_buf(vec[u8] buf, uint radix) -> uint {
auto i = _vec.len[u8](buf) - 1u;
auto power = 1u;
auto n = 0u;
- while (i >= 0u) {
+ while (true) {
n += (((buf.(i)) - ('0' as u8)) as uint) * power;
power *= radix;
- i -= 1u;
+ if (i == 0u) { ret n; }
}
- ret n;
}
fn to_str(uint num, uint radix) -> str