slurmrestd - Always free openapi_resp_single_t's contents
Before, endpoint 'POST /slurmdb/v0.0.4*/qos' did not free the contents of
openapi_resp_single_t after parsing. This can lead to a memory leak if the
user defined the warnings, errors, or meta field.
Ticket: 23400
Changelog: slurmrestd - Fix memory leak that happened when submitting a
request body containing the "warnings", "errors", or "meta" field. This
affects the following endpoints:
'POST /slurmdb/v0.0.4*/qos'
diff --git a/src/slurmrestd/plugins/openapi/slurmdbd/qos.c b/src/slurmrestd/plugins/openapi/slurmdbd/qos.c
index dbafd41..b1ad265 100644
--- a/src/slurmrestd/plugins/openapi/slurmdbd/qos.c
+++ b/src/slurmrestd/plugins/openapi/slurmdbd/qos.c
@@ -176,6 +176,7 @@
qos_list, ctxt);
} else if (ctxt->method == HTTP_REQUEST_POST) {
openapi_resp_single_t post = { 0 };
+ openapi_resp_single_t *post_ptr = &post;
if (!DATA_PARSE(ctxt->parser, OPENAPI_SLURMDBD_QOS_RESP, post,
ctxt->query, ctxt->parent_path) &&
@@ -183,6 +184,7 @@
qos_list = post.response;
update_qos(ctxt, true, qos_list);
}
+ FREE_OPENAPI_RESP_COMMON_CONTENTS(post_ptr);
} else {
resp_error(ctxt, ESLURM_REST_INVALID_QUERY, __func__,
"Unsupported HTTP method requested: %s",