From: Jonathan Neuschäfer Date: Tue, 12 Jun 2012 21:15:44 +0000 (+0200) Subject: strfsong: add a '\0' after copied chars; avoid memset X-Git-Tag: release-0.21~21 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=97f1070dbe2b179442201aaa702fbb5d52977e5c;p=ncmpc.git strfsong: add a '\0' after copied chars; avoid memset --- 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