Skip to content

Commit 73044b3

Browse files
committed
stdlib: Fix a crazy underflow bug in _uint.parse_buf. Oops.
1 parent 031e86c commit 73044b3

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/lib/_uint.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,11 @@ fn parse_buf(vec[u8] buf, uint radix) -> uint {
3737
auto i = _vec.len[u8](buf) - 1u;
3838
auto power = 1u;
3939
auto n = 0u;
40-
while (i >= 0u) {
40+
while (true) {
4141
n += (((buf.(i)) - ('0' as u8)) as uint) * power;
4242
power *= radix;
43-
i -= 1u;
43+
if (i == 0u) { ret n; }
4444
}
45-
ret n;
4645
}
4746

4847
fn to_str(uint num, uint radix) -> str

0 commit comments

Comments
 (0)