From ea5cbaeb3a28e1765f73ac67f9e18b849c52a7f9 Mon Sep 17 00:00:00 2001 From: 1-p Date: Tue, 12 Jul 2016 11:47:27 +0800 Subject: [PATCH 1/2] Fix editorUpdateSyntax `\t\\` leads to a crash due to `memset` with negative inputs in editorUpdateSyntax. --- kilo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kilo.c b/kilo.c index 9490a77..db4e904 100644 --- a/kilo.c +++ b/kilo.c @@ -398,7 +398,7 @@ void editorUpdateSyntax(erow *row) { /* Handle // 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; } From f0b377aab31de2814f1764df4abab414b8fad93d Mon Sep 17 00:00:00 2001 From: 1-p Date: Sat, 16 Jul 2016 10:22:21 +0800 Subject: [PATCH 2/2] Fix a crash on deleting row --- kilo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kilo.c b/kilo.c index db4e904..02a9409 100644 --- a/kilo.c +++ b/kilo.c @@ -603,7 +603,7 @@ void editorDelRow(int at) { row = E.row+at; editorFreeRow(row); memmove(E.row+at,E.row+at+1,sizeof(E.row[0])*(E.numrows-at-1)); - for (int j = at; j < E.numrows-1; j++) E.row[j].idx++; + for (int j = at; j < E.numrows-1; j++) E.row[j].idx--; E.numrows--; E.dirty++; }