summaryrefslogtreecommitdiffstats
path: root/RedfishPkg/PrivateLibrary
diff options
context:
space:
mode:
authorWenyi Xie <xiewenyi2@huawei.com>2022-03-10 17:02:14 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-03-11 08:05:46 +0000
commit2b175eeb6a3f630aef5a59a2c610a5be1a0cdd65 (patch)
tree03b4d5af991d218694fa53e4a9bdca3b5984d8df /RedfishPkg/PrivateLibrary
parentf06941cc46d002f66875b6f2f711fa3df2775da4 (diff)
downloadedk2-2b175eeb6a3f630aef5a59a2c610a5be1a0cdd65.tar.gz
edk2-2b175eeb6a3f630aef5a59a2c610a5be1a0cdd65.tar.bz2
edk2-2b175eeb6a3f630aef5a59a2c610a5be1a0cdd65.zip
RedfishPkg: fix memory leak issue
The calloc memory is not free when function collectionEvalOp return in the halfway. Cc: Abner Chang <abner.chang@hpe.com> Cc: Nickle Wang <nickle.wang@hpe.com> Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com> Reviewed-by: Abner Chang <abner.chang@hpe.com>
Diffstat (limited to 'RedfishPkg/PrivateLibrary')
-rw-r--r--RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c
index 3f2b83e834..6c6e2246ab 100644
--- a/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c
+++ b/RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c
@@ -620,6 +620,7 @@ collectionEvalOp (
if (((*StatusCode == NULL) && (members == NULL)) ||
((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
{
+ free (valid);
return members;
}
@@ -633,6 +634,7 @@ collectionEvalOp (
if (((*StatusCode == NULL) && (tmp == NULL)) ||
((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
{
+ free (valid);
return tmp;
}
@@ -658,19 +660,15 @@ collectionEvalOp (
cleanupPayload (members);
if (validCount == 0) {
- free (valid);
- return NULL;
- }
-
- if (validCount == 1) {
+ ret = NULL;
+ } else if (validCount == 1) {
ret = valid[0];
- free (valid);
- return ret;
} else {
ret = createCollection (payload->service, validCount, valid);
- free (valid);
- return ret;
}
+
+ free (valid);
+ return ret;
}
static redfishPayload *