nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 204e1b83534652ba8dc4b8e31b72bf5a30e01213
parent d865d7ac8ff15b4de4d1f1682def0978b57d68fa
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed,  7 Feb 2018 18:09:15 +0100

memory: squeal when there is something wrong, instead of stumbling on

When copying a string, source and destination may not be equal --
complain loudly when they are, instead of failing to free memory.

Also, instead of freeing the destination string and then allocating
it afresh, just reallocate it -- that should be slightly quicker.

Diffstat:
Msrc/utils.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/utils.c b/src/utils.c @@ -378,10 +378,10 @@ char *mallocstrncpy(char *dest, const char *src, size_t n) if (src == NULL) src = ""; - if (src != dest) - free(dest); + if (src == dest) + fprintf(stderr, "\r*** Copying a string to itself -- please report a bug ***"); - dest = charalloc(n); + dest = charealloc(dest, n); strncpy(dest, src, n); return dest;