From 658b8f53df5e13711632a36741e7c2b7a46ae8aa Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 19 Feb 2007 07:58:05 +0000 Subject: More (v)snprintf-related buffer over-allocations removed Also took out an unnecessary memset in getPlayerErrorStr git-svn-id: https://svn.musicpd.org/mpd/trunk@5396 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/log.c | 2 +- src/myfprintf.c | 2 +- src/player.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/log.c b/src/log.c index 77eadaa4e..ac6bbfa79 100644 --- a/src/log.c +++ b/src/log.c @@ -68,7 +68,7 @@ static const char *log_date(void) #define BUFFER_LENGTH 4096 static void buffer_warning(const char *fmt, va_list args) { - char buffer[BUFFER_LENGTH + 1]; + char buffer[BUFFER_LENGTH]; char *tmp = buffer; size_t len = BUFFER_LENGTH; diff --git a/src/myfprintf.c b/src/myfprintf.c index dac58ab34..4676c7193 100644 --- a/src/myfprintf.c +++ b/src/myfprintf.c @@ -50,7 +50,7 @@ static void blockingWrite(const int fd, const char *string, size_t len) void vfdprintf(const int fd, const char *fmt, va_list args) { - static char buffer[BUFFER_LENGTH + 1]; + static char buffer[BUFFER_LENGTH]; char *buf = buffer; size_t len; diff --git a/src/player.c b/src/player.c index 57ed1f2ef..25dbe777f 100644 --- a/src/player.c +++ b/src/player.c @@ -303,8 +303,8 @@ char *getPlayerErrorStr(void) int errorlen = MAXPATHLEN + 1024; PlayerControl *pc = &(getPlayerData()->playerControl); - error = xrealloc(error, errorlen + 1); - memset(error, 0, errorlen + 1); + error = xrealloc(error, errorlen); + error[0] = '\0'; switch (pc->error) { case PLAYER_ERROR_FILENOTFOUND: -- cgit v1.2.3