>From 825d93f98648119cab5a392d1d524fbc626b0b40 Mon Sep 17 00:00:00 2001 From: Alessandro Ghedini Date: Thu, 4 Jun 2015 11:42:38 +0200 Subject: [PATCH] Use strdup() to duplicate a buffer This apparently fixes the "Invalid read of size 4" error from valgrind that was reported at https://bugs.debian.org/724069 --- lib/idna.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/idna.c b/lib/idna.c index bf93bfe..17774d0 100644 --- a/lib/idna.c +++ b/lib/idna.c @@ -539,11 +539,9 @@ idna_to_ascii_4z (const uint32_t * input, char **output, int flags) } else { - size_t l = strlen (buf) + 1; - out = (char *) malloc (l); + out = strdup (buf); if (!out) return IDNA_MALLOC_ERROR; - strcpy (out, buf); } start = end + 1; -- 2.1.4