Issue #381: Fixed segfaults at logging

* This patch correctly handles varargs being used two times in the
  same function.
This commit is contained in:
Luka Krajger 2016-06-06 16:11:11 +02:00
parent cbac76e579
commit e6c25e84bc

View file

@ -100,7 +100,11 @@ void error(const char *fmt, ...) {
va_start(ap, fmt);
debugMsg(MSG_ERROR, fmt, ap);
#ifdef HAVE_SYSLOG_H
vsyslog(LOG_ERR, fmt, ap);
va_list apSyslog;
va_copy(apSyslog, ap);
va_start(apSyslog, fmt);
vsyslog(LOG_ERR, fmt, apSyslog);
va_end(apSyslog);
#endif
va_end(ap);
}
@ -117,7 +121,11 @@ void fatal(const char *fmt, ...) {
va_start(ap, fmt);
debugMsg(MSG_QUIET, fmt, ap);
#ifdef HAVE_SYSLOG_H
vsyslog(LOG_CRIT, fmt, ap);
va_list apSyslog;
va_copy(apSyslog, ap);
va_start(apSyslog, fmt);
vsyslog(LOG_CRIT, fmt, apSyslog);
va_end(apSyslog);
syslog(LOG_CRIT, "[server] Aborting...");
#endif
va_end(ap);