Moved allocation of response JSON to avoid memory being lost in error condition
@@ -490,14 +490,6 @@ ACVP_RESULT acvp_kdf108_kat_handler(ACVP_CTX *ctx, JSON_Object *obj) {
ACVP_LOG_INFO(" keyIn: %s", key_in_str);
ACVP_LOG_INFO(" deferred: %d", deferred);
- /*
- * Create a new test case in the response
- */
- r_tval = json_value_init_object();
- r_tobj = json_value_get_object(r_tval);
-
- json_object_set_number(r_tobj, "tcId", tc_id);
-
/*
* Setup the test case data that will be passed down to
* the crypto module.
@@ -518,6 +510,14 @@ ACVP_RESULT acvp_kdf108_kat_handler(ACVP_CTX *ctx, JSON_Object *obj) {
goto err;
}
+ /*
+ * Create a new test case in the response
+ */
+ r_tval = json_value_init_object();
+ r_tobj = json_value_get_object(r_tval);
+
+ json_object_set_number(r_tobj, "tcId", tc_id);
+
/*
* Output the test case results using JSON
*/
