From d6435b37ef26ab3d4f6e61fc8c07eea77a521189 Mon Sep 17 00:00:00 2001 From: Luke Parker <25259837+kayabaNerve@users.noreply.github.com> Date: Sun, 5 Aug 2018 16:47:05 -0500 Subject: [PATCH] Stop single digit strings from throwing an IndexError on `parse` (#59) --- stint/io.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stint/io.nim b/stint/io.nim index ddec855..87f1f22 100644 --- a/stint/io.nim +++ b/stint/io.nim @@ -90,6 +90,9 @@ func skipPrefixes(current_idx: var int, str: string, base: range[2..16]) {.inlin ## Returns the index of the first meaningful char in `hexStr` by skipping ## "0x" prefix + if str.len < 2: + return + assert current_idx == 0, "skipPrefixes only works for prefixes (position 0 and 1 of the string)" if str[0] == '0': if str[1] in {'x', 'X'}: