The memory returned by json_dumps() must be freed.
Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
---
RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
index 126200dd019c..250ef75e40de 100644
--- a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
+++ b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
@@ -379,15 +379,19 @@ CreateCsJsonByNode (
if (TempChar != NULL) {
Status = allocateRecordCsMemory (Cs, sizeof (RedfishCS_Type_JSON_Data), (void **)&CsTypeJson);
if (Status != RedfishCS_status_success) {
+ free (TempChar);
return Status;
}
Status = allocateRecordCsMemory (Cs, (RedfishCS_int)strlen (TempChar) + 1, (void **)&DumpStr);
if (Status != RedfishCS_status_success) {
+ free (TempChar);
return Status;
}
strncpy (DumpStr, TempChar, strlen (TempChar) + 1);
+ free (TempChar);
+
InitializeLinkHead (&CsTypeJson->Header.LinkEntry);
CsTypeJson->Header.ResourceType = RedfishCS_Type_JSON;
CsTypeJson->Header.ThisUri = ParentUri;
@@ -1506,9 +1510,10 @@ RemoveUnchangeableProperties (
Status = RedfishCS_status_insufficient_memory;
} else {
memcpy (NewJsonBuffer, TempChar, strlen (TempChar) + 1);
- free (TempChar);
Status = RedfishCS_status_success;
}
+
+ free (TempChar);
} else {
Status = RedfishCS_status_unknown_error;
}
--
2.32.0 (Apple Git-132)
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114645): https://edk2.groups.io/g/devel/message/114645
Mute This Topic: https://groups.io/mt/103988340/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-