From a69a33f49839d4977ab9d6168644f69ff4c65d4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Wed, 19 Oct 2011 22:27:47 +0200 Subject: [PATCH] screen_lyrics: fix lyrics_title on small screens It turns out snprintf returns the length of the resulting string, not the actual number of bytes copied into the buffer, e.g. the following call will return 33, and not 7 (or 8): snprintf(buffer, 8, "this string is 33 characters long"); This patch also adds empty lines around the code dealing with the plugin name to help readabiliy. --- src/screen_lyrics.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index 0e21536..e655fc5 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -313,9 +313,12 @@ lyrics_title(char *str, size_t size) n = snprintf(str, size, "%s: %s - %s", _("Lyrics"), current.artist, current.title); - if (options.lyrics_show_plugin && current.plugin_name != NULL) + + if (options.lyrics_show_plugin && current.plugin_name != NULL && + (unsigned int) n < size - 1) snprintf(str + n, size - n, " (%s)", current.plugin_name); + return str; } else return _("Lyrics"); -- 2.30.2