diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-11-25 11:26:08 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-11-25 11:28:05 -0800 |
commit | 05f4482139262d3c1ddc2f884fb7c19fdf4e450f (patch) | |
tree | d2d6bf75f7deee057a75dee0038d557eea31ef97 /src/kilo.c | |
parent | 6727045165a5f5f007c9ae69389b7963f458f6c0 (diff) | |
download | teliva-05f4482139262d3c1ddc2f884fb7c19fdf4e450f.tar.gz |
make upstream kilo ASan-clean
Many thanks to dirkf for https://github.com/antirez/kilo/pull/73! However, teliva is still not ASan-clean.
Diffstat (limited to 'src/kilo.c')
-rw-r--r-- | src/kilo.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/kilo.c b/src/kilo.c index 1e672c1..7ddfa39 100644 --- a/src/kilo.c +++ b/src/kilo.c @@ -244,14 +244,14 @@ static void editorUpdateSyntax(erow *row) { /* Handle single-line comments. */ if (prev_sep && *p == scs[0] && *(p+1) == scs[1]) { /* From here to end is a comment */ - memset(row->hl+i,HL_COMMENT,row->size-i); + memset(row->hl+i,HL_COMMENT,row->rsize-i); return; } /* Handle "" and '' */ if (in_string) { row->hl[i] = HL_STRING; - if (*p == '\\') { + if (*p == '\\' && *(p+1)) { row->hl[i+1] = HL_STRING; p += 2; i += 2; prev_sep = 0; @@ -290,12 +290,13 @@ static void editorUpdateSyntax(erow *row) { /* Handle keywords and lib calls */ if (prev_sep) { int j; + int ileft = row->rsize-i; for (j = 0; keywords[j]; j++) { int klen = strlen(keywords[j]); int kw2 = keywords[j][klen-1] == '|'; if (kw2) klen--; - if (!memcmp(p,keywords[j],klen) && + if (klen < ileft && !memcmp(p,keywords[j],klen) && is_separator(*(p+klen))) { /* Keyword */ |