aboutsummaryrefslogtreecommitdiff
path: root/nxcompshad
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2019-09-18 23:47:24 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-09-29 17:17:06 +0200
commit506378cf2134c5c4b36f0441100ab806307fd832 (patch)
tree8d7ea40b0844378b980f9f414f4753334defa303 /nxcompshad
parentdf9d37da58c0f10a7c5aed2af5ccb8a130c7a5b4 (diff)
downloadnx-libs-506378cf2134c5c4b36f0441100ab806307fd832.tar.gz
nx-libs-506378cf2134c5c4b36f0441100ab806307fd832.tar.bz2
nx-libs-506378cf2134c5c4b36f0441100ab806307fd832.zip
nxcompshad: fix logging segfault
One cannot simply pass down a va_list to another function that expects variable arguments ("..."). The prototype of the called functions must expect a va_list argument instead. This fixes segfaults that happen e.g. after compiling X11.cpp with TEST and effectively reverts 59e829f3647005a6c93662adfbcea36e27a993d8.
Diffstat (limited to 'nxcompshad')
-rw-r--r--nxcompshad/src/Logger.cpp20
-rw-r--r--nxcompshad/src/Logger.h8
2 files changed, 8 insertions, 20 deletions
diff --git a/nxcompshad/src/Logger.cpp b/nxcompshad/src/Logger.cpp
index 2f3eab65c..9648509b8 100644
--- a/nxcompshad/src/Logger.cpp
+++ b/nxcompshad/src/Logger.cpp
@@ -41,14 +41,11 @@
Logger logger;
-void Logger::user(const char *format, ...)
+void Logger::user(const char *format, va_list arguments)
{
char string[1024];
- va_list arguments;
- va_start(arguments, format);
vsnprintf(string, 1024, format, arguments);
- va_end(arguments);
fprintf(stderr, "%s\n", string);
}
@@ -59,26 +56,20 @@ void Logger::error(const char *name, int error)
name, error, strerror(error));
}
-void Logger::warning(const char *name, const char *format, ...)
+void Logger::warning(const char *name, const char *format, va_list arguments)
{
char string[1024];
- va_list arguments;
- va_start(arguments, format);
vsnprintf(string, 1024, format, arguments);
- va_end(arguments);
fprintf(stderr, "%s: WARNING! %s\n", name, string);
}
-void Logger::test(const char *name, const char *format, ...)
+void Logger::test(const char *name, const char *format, va_list arguments)
{
char string[1024];
- va_list arguments;
- va_start(arguments, format);
vsnprintf(string, 1024, format, arguments);
- va_end(arguments);
fprintf(stderr, "%s: %s\n", name, string);
}
@@ -88,14 +79,11 @@ void Logger::trace(const char *name)
fprintf(stderr, "%s\n", name);
}
-void Logger::debug(const char *name, const char *format, ...)
+void Logger::debug(const char *name, const char *format, va_list arguments)
{
char string[1024];
- va_list arguments;
- va_start(arguments, format);
vsnprintf(string, 1024, format, arguments);
- va_end(arguments);
fprintf(stderr, "%s: %s\n", name, string);
}
diff --git a/nxcompshad/src/Logger.h b/nxcompshad/src/Logger.h
index 8436c5f15..c4c46fe9a 100644
--- a/nxcompshad/src/Logger.h
+++ b/nxcompshad/src/Logger.h
@@ -43,17 +43,17 @@ class Logger
{
public:
- void user(const char *format, ...) __attribute__((format(printf, 2, 0)));
+ void user(const char *format, va_list arguments) __attribute__((format(printf, 2, 0)));
void error(const char *name, int error);
- void warning(const char *name, const char *format, ...) __attribute__((format(printf, 3, 0)));
+ void warning(const char *name, const char *format, va_list arguments) __attribute__((format(printf, 3, 0)));
- void test(const char *name, const char *format, ...) __attribute__((format(printf, 3, 0)));
+ void test(const char *name, const char *format, va_list arguments) __attribute__((format(printf, 3, 0)));
void trace(const char *name);
- void debug(const char *name, const char *format, ...) __attribute__((format(printf, 3, 0)));
+ void debug(const char *name, const char *format, va_list arguments) __attribute__((format(printf, 3, 0)));
void dump(const char *name, const char *data, int size);
};