Skip to content

Commit

Permalink
Fix memory leaks in ipctest
Browse files Browse the repository at this point in the history
Ref: #1108
  • Loading branch information
michalbiesek committed Jan 31, 2023
1 parent 57b3cdf commit b25920e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/unit/library/ipctest.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ ipcHandlerRequestKnown(void **state) {
assert_int_equal(parseStatus, REQ_PARSE_OK);
assert_string_equal(scopeReq, msg->scopeData);
assert_int_equal(uniqueId, 1234);
scope_free(scopeReq);

destroyIpcMessage(msg);

Expand Down Expand Up @@ -389,6 +390,7 @@ ipcHandlerRequestUnknown(void **state) {
assert_int_equal(parseStatus, REQ_PARSE_OK);
assert_string_equal(scopeReq, msg->scopeData);
assert_int_equal(uniqueId, 4567);
scope_free(scopeReq);

destroyIpcMessage(msg);

Expand Down Expand Up @@ -570,6 +572,7 @@ ipcHandlerScopeResponseValid(void **state) {
assert_non_null(mqResp);
char *mqRespBytes = cJSON_PrintUnformatted(mqResp);
size_t mqRespLenWithNul = scope_strlen(mqRespBytes) + 1;
scope_free(mqRespBytes);

item = cJSON_GetObjectItemCaseSensitive(mqResp, "status");
assert_non_null(item);
Expand Down Expand Up @@ -644,6 +647,7 @@ ipcHandlerScopeResponseUnknown(void **state) {
assert_non_null(mqResp);
char *mqRespBytes = cJSON_PrintUnformatted(mqResp);
size_t mqRespLenWithNul = scope_strlen(mqRespBytes) + 1;
scope_free(mqRespBytes);

item = cJSON_GetObjectItemCaseSensitive(mqResp, "status");
assert_non_null(item);
Expand Down Expand Up @@ -720,6 +724,7 @@ ipcHandlerScopeResponseGetCfgSingleMsg(void **state) {
assert_non_null(mqResp);
char *mqRespBytes = cJSON_PrintUnformatted(mqResp);
size_t mqRespLenWithNul = scope_strlen(mqRespBytes) + 1;
scope_free(mqRespBytes);

item = cJSON_GetObjectItemCaseSensitive(mqResp, "status");
assert_non_null(item);
Expand All @@ -745,8 +750,8 @@ ipcHandlerScopeResponseGetCfgSingleMsg(void **state) {
assert_non_null(itemCurrentCfg);
assert_true(cJSON_IsObject(itemCurrentCfg));
char *scopeCfgBytes = cJSON_PrintUnformatted(itemCurrentCfg);

cfgRecv = cfgFromString(scopeCfgBytes);
scope_free(scopeCfgBytes);
assert_int_equal(cfgLogLevel(cfgRecv), CFG_LOG_TRACE);

cfgDestroy(&cfgRecv);
Expand Down Expand Up @@ -796,6 +801,8 @@ ipcHandlerScopeResponseSetCfgSingleMsg(void **state) {
char *setCfgMsg = cJSON_PrintUnformatted(setCfgMsgJson);

ipc_msg_t *msg = createIpcMessage("{\"req\":0,\"uniq\":1234,\"remain\":128}", setCfgMsg);
scope_free(setCfgMsg);

res = ipcSendSuccessfulResponse(mqReadWriteDes, attr.mq_msgsize, msg->scopeData, uniqueId);
assert_int_equal(res, RESP_RESULT_OK);

Expand Down

0 comments on commit b25920e

Please sign in to comment.