summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 524d59d)
raw | patch | inline | side by side (parent: 524d59d)
author | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | |
Wed, 19 Oct 2011 20:27:47 +0000 (22:27 +0200) | ||
committer | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | |
Wed, 19 Oct 2011 20:36:25 +0000 (22:36 +0200) |
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.
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 | patch | blob | history |
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index 0e21536b2f0c5ea2fa643d23a04ef556686f9d99..e655fc5f37c1fcb53e2ce79d62b9c4be3aa0bb67 100644 (file)
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
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");