diff --git a/src/utils.c b/src/utils.c index 7ae436e0..dcf4014c 100644 --- 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;