VNOTE: rather use memcpy if we know the length to copy anyways.
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 21 Oct 2012 20:28:42 +0000 (22:28 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 21 Oct 2012 20:28:42 +0000 (22:28 +0200)
libcitadel/lib/vnote.c

index 3507a4087f697fec74636fdf2ad7e1a3a7f800df..c8f45b98c83e8ae5a3acab88ac28c8aeb3c58ef9 100644 (file)
@@ -80,10 +80,10 @@ struct vnote *vnote_new_from_str(char *s) {
                thisline = NULL;
                nexteol = strchr(ptr, '\n');
                if (nexteol) {
-                       thisline = malloc((nexteol - ptr) + 2);
-                       strncpy(thisline, ptr, (nexteol-ptr));
                        thisline_len = (nexteol-ptr);
-                       thisline[thisline_len] = 0;
+                       thisline = malloc(thisline_len + 2);
+                       memcpy(thisline, ptr, thisline_len);
+                       thisline[thisline_len] = '\0';
                        ptr = nexteol + 1;
                }
                else {