From 97f1070dbe2b179442201aaa702fbb5d52977e5c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Tue, 12 Jun 2012 23:15:44 +0200 Subject: [PATCH] strfsong: add a '\0' after copied chars; avoid memset --- src/strfsong.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/strfsong.c b/src/strfsong.c index e3d4eb9..4e9b8d6 100644 --- a/src/strfsong.c +++ b/src/strfsong.c @@ -119,7 +119,8 @@ _strfsong(gchar *s, gsize n, length = 0; gboolean found = FALSE; - memset(s, 0, max); + s[0] = '\0'; + if (song == NULL) return 0; @@ -128,7 +129,7 @@ _strfsong(gchar *s, if (p[0] == '|') { ++p; if(!found) { - memset(s, 0, max); + s[0] = '\0'; length = 0; } else { p = skip(p); @@ -163,7 +164,7 @@ _strfsong(gchar *s, if (p[0] == ']') { if(last) *last = p+1; if(!found && length) { - memset(s, 0, max); + s[0] = '\0'; length = 0; } return length; @@ -172,6 +173,7 @@ _strfsong(gchar *s, /* pass-through non-escaped portions of the format string */ if (p[0] != '#' && p[0] != '%' && length