debug: workaround for strange va_list corruption bug
diff --git a/openbsc/src/debug.c b/openbsc/src/debug.c
index 30e27a8..15271fe 100644
--- a/openbsc/src/debug.c
+++ b/openbsc/src/debug.c
@@ -223,8 +223,15 @@
 			output = 1;
 		}
 
-		if (output)
-			_output(tar, subsys, file, line, cont, format, ap);
+		if (output) {
+			/* FIXME: copying the va_list is an ugly workaround against a bug
+			 * hidden somewhere in _output.  If we do not copy here, the first
+			 * call to _output() will corrupt the va_list contents, and any
+			 * further _output() calls with the same va_list will segfault */
+			va_list bp;
+			va_copy(bp, ap);
+			_output(tar, subsys, file, line, cont, format, bp);
+		}
 	}
 }