diff options
author | alaviss <alaviss@users.noreply.github.com> | 2018-12-26 03:08:16 +0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-12-25 21:08:16 +0100 |
commit | 58d293d6a98b56ed4b309491f09492618c3fa9ec (patch) | |
tree | e1cbc7e32ebbd80342056afabd1eda9c35d5f49b /nimsuggest | |
parent | 5f2b66751ac0a3115e6b4760f067332e80264195 (diff) | |
download | Nim-58d293d6a98b56ed4b309491f09492618c3fa9ec.tar.gz |
fixes nim-lang/nimsuggest#76 (#10093)
* nimsuggest: prevent out-of-bound access * fixes nim-lang/nimsuggest#76 * undo tester changes
Diffstat (limited to 'nimsuggest')
-rw-r--r-- | nimsuggest/nimsuggest.nim | 4 | ||||
-rw-r--r-- | nimsuggest/tests/ttype_highlight.nim | 28 |
2 files changed, 30 insertions, 2 deletions
diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index c8c6101d7..c24a8bafa 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -99,7 +99,7 @@ type proc parseQuoted(cmd: string; outp: var string; start: int): int = var i = start i += skipWhitespace(cmd, i) - if cmd[i] == '"': + if i < cmd.len and cmd[i] == '"': i += parseUntil(cmd, outp, '"', i+1)+2 else: i += parseUntil(cmd, outp, seps, i) @@ -428,7 +428,7 @@ proc execCmd(cmd: string; graph: ModuleGraph; cachedMsgs: CachedMsgs) = var dirtyfile = "" var orig = "" i = parseQuoted(cmd, orig, i) - if cmd[i] == ';': + if i < cmd.len and cmd[i] == ';': i = parseQuoted(cmd, dirtyfile, i+1) i += skipWhile(cmd, seps, i) var line = -1 diff --git a/nimsuggest/tests/ttype_highlight.nim b/nimsuggest/tests/ttype_highlight.nim new file mode 100644 index 000000000..e4189a015 --- /dev/null +++ b/nimsuggest/tests/ttype_highlight.nim @@ -0,0 +1,28 @@ +type + TypeA = int + TypeB* = int + TypeC {.unchecked.} = array[1, int] + TypeD[T] = T + TypeE* {.unchecked.} = array[0, int]#[!]# + +discard """ +disabled:true +$nimsuggest --tester $file +>highlight $1 +highlight;;skType;;2;;2;;5 +highlight;;skType;;3;;2;;5 +highlight;;skType;;4;;2;;5 +highlight;;skType;;5;;2;;5 +highlight;;skType;;6;;2;;5 +highlight;;skType;;2;;10;;3 +highlight;;skType;;3;;11;;3 +highlight;;skType;;4;;24;;5 +highlight;;skType;;4;;33;;3 +highlight;;skType;;5;;13;;1 +highlight;;skType;;6;;25;;5 +highlight;;skType;;6;;34;;3 +highlight;;skType;;2;;10;;3 +highlight;;skType;;3;;11;;3 +highlight;;skType;;4;;33;;3 +highlight;;skType;;6;;34;;3 +""" |