summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/bpf/bpftool/jit_disasm.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/bpf/bpftool/jit_disasm.c b/tools/bpf/bpftool/jit_disasm.c
index 3ef3093560ba..bfed711258ce 100644
--- a/tools/bpf/bpftool/jit_disasm.c
+++ b/tools/bpf/bpftool/jit_disasm.c
@@ -11,6 +11,8 @@
11 * Licensed under the GNU General Public License, version 2.0 (GPLv2) 11 * Licensed under the GNU General Public License, version 2.0 (GPLv2)
12 */ 12 */
13 13
14#define _GNU_SOURCE
15#include <stdio.h>
14#include <stdarg.h> 16#include <stdarg.h>
15#include <stdint.h> 17#include <stdint.h>
16#include <stdio.h> 18#include <stdio.h>
@@ -44,11 +46,13 @@ static int fprintf_json(void *out, const char *fmt, ...)
44 char *s; 46 char *s;
45 47
46 va_start(ap, fmt); 48 va_start(ap, fmt);
49 if (vasprintf(&s, fmt, ap) < 0)
50 return -1;
51 va_end(ap);
52
47 if (!oper_count) { 53 if (!oper_count) {
48 int i; 54 int i;
49 55
50 s = va_arg(ap, char *);
51
52 /* Strip trailing spaces */ 56 /* Strip trailing spaces */
53 i = strlen(s) - 1; 57 i = strlen(s) - 1;
54 while (s[i] == ' ') 58 while (s[i] == ' ')
@@ -61,11 +65,10 @@ static int fprintf_json(void *out, const char *fmt, ...)
61 } else if (!strcmp(fmt, ",")) { 65 } else if (!strcmp(fmt, ",")) {
62 /* Skip */ 66 /* Skip */
63 } else { 67 } else {
64 s = va_arg(ap, char *);
65 jsonw_string(json_wtr, s); 68 jsonw_string(json_wtr, s);
66 oper_count++; 69 oper_count++;
67 } 70 }
68 va_end(ap); 71 free(s);
69 return 0; 72 return 0;
70} 73}
71 74