summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlains <lains@caramail.com>2018-04-30 18:04:46 +0200
committerjkoan <jkoan@users.noreply.github.com>2018-04-30 18:04:46 +0200
commit4231cac78eebbc761a4a356292aa79693384254f (patch)
tree594bf7223349eebd316265f279a259f50c65333b
parentc3a13917312f7a376656264ae2e4d509028a2481 (diff)
downloadnavit-4231cac78eebbc761a4a356292aa79693384254f.tar.gz
fix:core:Fixing dbg() change introduced in 221f783ea1caaaab2f5ceadc6b0fb3e720aac3df (#560)
-rw-r--r--navit/debug.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/navit/debug.c b/navit/debug.c
index 3fd1c5386..d8277f761 100644
--- a/navit/debug.c
+++ b/navit/debug.c
@@ -308,14 +308,14 @@ debug_vprintf(dbg_level level, const char *module, const int mlen, const char *f
#if defined HAVE_API_WIN32_CE
#define vsnprintf _vsnprintf
#endif
- gchar *fmt_newline;
+ vsnprintf(debug_message+strlen(debug_message),sizeof(debug_message)-1-strlen(debug_message),fmt,ap);
#ifdef HAVE_API_WIN32_BASE
- fmt_newline = g_strconcat(fmt, "\r\n");
-#else
- fmt_newline = g_strconcat(fmt, "\n");
+ if (strlen(debug_message)<sizeof(debug_message))
+ debug_message[strlen(debug_message)] = '\r'; /* For Windows platforms, add \r at the end of the buffer (if any room) */
#endif
- vsnprintf(debug_message+strlen(debug_message),4095-strlen(debug_message),fmt_newline,ap);
- g_free(fmt_newline);
+ if (strlen(debug_message)<sizeof(debug_message))
+ debug_message[strlen(debug_message)] = '\n'; /* Add \n at the end of the buffer (if any room) */
+ debug_message[sizeof(debug_message)-1] = '\0'; /* Force NUL-termination of the string (if buffer size contraints did not allow for full string to fit */
#ifdef DEBUG_WIN32_CE_MESSAGEBOX
mbstowcs(muni, debug_message, strlen(debug_message)+1);
MessageBoxW(NULL, muni, TEXT("Navit - Error"), MB_APPLMODAL|MB_OK|MB_ICONERROR);