diff mbox

[libnftnl,3/4] expr: meta: Delete the last comma character in json text.

Message ID 1403368200-8860-4-git-send-email-anarey@gmail.com
State Accepted
Headers show

Commit Message

Ana Rey June 21, 2014, 4:29 p.m. UTC
Code refactoring to delete correctly the last comma character in json text.

Signed-off-by: Ana Rey <anarey@gmail.com>
---
 src/expr/meta.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/src/expr/meta.c b/src/expr/meta.c
index 25026a9..95d538c 100644
--- a/src/expr/meta.c
+++ b/src/expr/meta.c
@@ -322,9 +322,10 @@  nft_rule_expr_meta_snprintf_json(char *buf, size_t size,
 	}
 
 	/* Remove the last separator characther */
-	buf[offset-1] = '\0';
+	if (offset > 0)
+		offset--;
 
-	return offset-1;
+	return offset;
 }
 
 static int