mirror of
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git
synced 2024-11-14 21:44:41 +08:00
lnstat: Fix deref of null in print_json() function
Now pointer `jw` is being checked for NULL before using in function `jsonw_start_object`. Added exit from function when `jw==NULL`. Found by RASU JSC Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
parent
3a882b6b4e
commit
a193733b7a
@ -112,6 +112,10 @@ static void print_json(FILE *of, const struct lnstat_file *lnstat_files,
|
||||
json_writer_t *jw = jsonw_new(of);
|
||||
int i;
|
||||
|
||||
if (jw == NULL) {
|
||||
fprintf(stderr, "Failed to create JSON writer\n");
|
||||
exit(1);
|
||||
}
|
||||
jsonw_start_object(jw);
|
||||
for (i = 0; i < fp->num; i++) {
|
||||
const struct lnstat_field *lf = fp->params[i].lf;
|
||||
|
Loading…
Reference in New Issue
Block a user