From f600a48847de75cbbe5dac8478b47e91b977f931 Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Tue, 24 Dec 2013 11:54:31 +0000 Subject: [PATCH] Fixed popup_message(). The second argument to _vsntprintf_s() is a count not a size. The fallback errors weren't massively helpful. The message buffer is too small for some larger messages. --- event.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/event.cpp b/event.cpp index bd06363..6744da2 100644 --- a/event.cpp +++ b/event.cpp @@ -73,15 +73,15 @@ int popup_message(unsigned int type, unsigned long id, ...) { TCHAR *format = message_string(id); if (! format) { - return MessageBox(0, _T("Message %lu was supposed to go here!"), NSSM, MB_OK | MB_ICONEXCLAMATION); + return MessageBox(0, _T("The message which was supposed to go here is missing!"), NSSM, MB_OK | MB_ICONEXCLAMATION); } - TCHAR blurb[256]; + TCHAR blurb[512]; va_start(arg, id); - if (_vsntprintf_s(blurb, sizeof(blurb), _TRUNCATE, format, arg) < 0) { + if (_vsntprintf_s(blurb, _countof(blurb), _TRUNCATE, format, arg) < 0) { va_end(arg); LocalFree(format); - return MessageBox(0, _T("Message %lu was supposed to go here!"), NSSM, MB_OK | MB_ICONEXCLAMATION); + return MessageBox(0, _T("the message which was supposed to go here is too big!"), NSSM, MB_OK | MB_ICONEXCLAMATION); } va_end(arg); -- 2.7.4