Skip to content

Commit

Permalink
doveadm: doveadm-print-json - Prevent crash on subsequent user prints
Browse files Browse the repository at this point in the history
Move closing the final json array delimiter to the deinitialization
routine instead of on flush.
  • Loading branch information
fleischie committed Oct 10, 2024
1 parent 5d1592b commit 5f66f3f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/doveadm/doveadm-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,13 @@ static void doveadm_print_json_flush(void)

if (ctx.json_output == NULL)
doveadm_print_json_init_output();
json_ostream_nascend_array(ctx.json_output);
json_ostream_nflush(ctx.json_output);
}

static void doveadm_print_json_deinit(void)
{
if (ctx.json_output != NULL)
json_ostream_nascend_array(ctx.json_output);
json_ostream_destroy(&ctx.json_output);
pool_unref(&ctx.pool);
}
Expand Down

0 comments on commit 5f66f3f

Please sign in to comment.