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/http_htx.c b/src/http_htx.c
index fb6c70a..41211bb 100644
--- a/src/http_htx.c
+++ b/src/http_htx.c
@@ -2618,17 +2618,17 @@
return 0;
}
if (arg[0].data.str.data == 4 && !strncmp(arg[0].data.str.area, "head", 4)) {
- free(arg[0].data.str.area);
+ chunk_destroy(&arg[0].data.str);
arg[0].type = ARGT_SINT;
arg[0].data.sint = -1;
}
else if (arg[0].data.str.data == 4 && !strncmp(arg[0].data.str.area, "tail", 4)) {
- free(arg[0].data.str.area);
+ chunk_destroy(&arg[0].data.str);
arg[0].type = ARGT_SINT;
arg[0].data.sint = -2;
}
else if (arg[0].data.str.data == 5 && !strncmp(arg[0].data.str.area, "first", 5)) {
- free(arg[0].data.str.area);
+ chunk_destroy(&arg[0].data.str);
arg[0].type = ARGT_SINT;
arg[0].data.sint = -3;
}
@@ -2647,7 +2647,7 @@
memprintf(err_msg, "block position must not be negative");
return 0;
}
- free(arg[0].data.str.area);
+ chunk_destroy(&arg[0].data.str);
arg[0].type = ARGT_SINT;
arg[0].data.sint = pos;
}