tuc: store a pointer to the terminating zero in uc_chop() - neatvi - [fork] simple vi-type editor with UTF-8 support
git clone git://src.adamsgaard.dk/neatvi
Log
Files
Refs
README
---
commit 6831be74582cbec67c8fcba98df286fbf8839015
parent 4b7eb1d70cfc9a1ac8d1bd602d461b60f40ba3f5
Author: Ali Gholami Rudi 
Date:   Sat,  9 May 2015 00:09:54 +0430

uc: store a pointer to the terminating zero in uc_chop()

Diffstat:
  M uc.c                                |       4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/uc.c b/uc.c
t@@ -86,8 +86,8 @@ char **uc_chop(char *s, int *n)
         char **chrs;
         int i;
         *n = uc_slen(s);
-        chrs = malloc(*n * sizeof(chrs[0]));
-        for (i = 0; i < *n; i++) {
+        chrs = malloc((*n + 1) * sizeof(chrs[0]));
+        for (i = 0; i < *n + 1; i++) {
                 chrs[i] = s;
                 s = uc_next(s);
         }