Message ID | 1403592401-5057-4-git-send-email-anarey@gmail.com |
---|---|
State | Accepted |
Headers | show |
diff --git a/src/expr/ct.c b/src/expr/ct.c index 49fe238..f2718f9 100644 --- a/src/expr/ct.c +++ b/src/expr/ct.c @@ -356,9 +356,10 @@ nft_expr_ct_snprintf_json(char *buf, size_t size, struct nft_rule_expr *e) } /* Remove the last separator characther */ - buf[offset-1] = '\0'; + if (offset > 0) + offset--; - return offset-1; + return offset; } static int
Code refactoring to delete correctly the last comma character in json text. Signed-off-by: Ana Rey <anarey@gmail.com> --- src/expr/ct.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)