From ca422c9bc6d9b352ade3e418958241ad79939a02 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 16 Apr 2011 15:28:37 +0300 Subject: Change vsprintf to vsnprintf. Like was in mana commit bb795d87f9d0eebb6cc04b5c6806252fbb957f5d --- src/log.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/log.cpp b/src/log.cpp index 982f2eed7..abd6beb76 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -144,15 +144,16 @@ void Logger::log(const char *log_text, ...) { unsigned size = 1024; char* buf = 0; - if (strlen(log_text) * 3 > size) + if (strlen(log_text) * 3> size) size = static_cast(strlen(log_text) * 3); - buf = new char[size]; + buf = new char[size + 1]; va_list ap; // Use a temporary buffer to fill in the variables va_start(ap, log_text); - vsprintf(buf, log_text, ap); + vsnprintf(buf, size, log_text, ap); + buf[size] = 0; va_end(ap); // Get the current system time -- cgit v1.2.3-60-g2f50