|
@@ -10,6 +10,8 @@
|
|
|
* Licensed under the GNU General Public License, version 2.0 (GPLv2)
|
|
* Licensed under the GNU General Public License, version 2.0 (GPLv2)
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
+#define _GNU_SOURCE
|
|
|
|
|
+#include <stdio.h>
|
|
|
#include <stdarg.h>
|
|
#include <stdarg.h>
|
|
|
#include <stdint.h>
|
|
#include <stdint.h>
|
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
@@ -51,11 +53,13 @@ static int fprintf_json(void *out, const char *fmt, ...)
|
|
|
char *s;
|
|
char *s;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
va_start(ap, fmt);
|
|
|
|
|
+ if (vasprintf(&s, fmt, ap) < 0)
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ va_end(ap);
|
|
|
|
|
+
|
|
|
if (!oper_count) {
|
|
if (!oper_count) {
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
- s = va_arg(ap, char *);
|
|
|
|
|
-
|
|
|
|
|
/* Strip trailing spaces */
|
|
/* Strip trailing spaces */
|
|
|
i = strlen(s) - 1;
|
|
i = strlen(s) - 1;
|
|
|
while (s[i] == ' ')
|
|
while (s[i] == ' ')
|
|
@@ -68,11 +72,10 @@ static int fprintf_json(void *out, const char *fmt, ...)
|
|
|
} else if (!strcmp(fmt, ",")) {
|
|
} else if (!strcmp(fmt, ",")) {
|
|
|
/* Skip */
|
|
/* Skip */
|
|
|
} else {
|
|
} else {
|
|
|
- s = va_arg(ap, char *);
|
|
|
|
|
jsonw_string(json_wtr, s);
|
|
jsonw_string(json_wtr, s);
|
|
|
oper_count++;
|
|
oper_count++;
|
|
|
}
|
|
}
|
|
|
- va_end(ap);
|
|
|
|
|
|
|
+ free(s);
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|