MINOR: arg: Use chunk_destroy() to release string arguments
This way, all fields of the buffer structure are reset when a string argument
(ARGT_STR) is released. It is also a good way to explicitly specify this kind
of argument is a chunk. So .data and .size fields must be set.
This patch may be backported to ease backports.
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index ae09aea..091772d 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -1502,12 +1502,12 @@
{
if (args[0].type == ARGT_STR) {
if (strcmp(args[0].data.str.area, "us") == 0) {
- free(args[0].data.str.area);
+ chunk_destroy(&args[0].data.str);
args[0].type = ARGT_SINT;
args[0].data.sint = TIME_UNIT_US;
}
else if (strcmp(args[0].data.str.area, "ms") == 0) {
- free(args[0].data.str.area);
+ chunk_destroy(&args[0].data.str);
args[0].type = ARGT_SINT;
args[0].data.sint = TIME_UNIT_MS;
}
@@ -1536,7 +1536,7 @@
if (args[0].type != ARGT_STOP) {
ha_warning("no argument supported for 'fc_*' sample expressions returning counters.\n");
if (args[0].type == ARGT_STR)
- free(args[0].data.str.area);
+ chunk_destroy(&args[0].data.str);
args[0].type = ARGT_STOP;
}