iSulad/0020-improve-code-in-utils_mount_spec.patch
Neil.wrz 669b58aed9 bugfix for cleanup module memory leak
Signed-off-by: Neil.wrz <wangrunze13@huawei.com>
2022-11-02 02:00:06 -07:00

46 lines
1.3 KiB
Diff

From 99df201139e1afbc719f78bae047eaf826676b7f Mon Sep 17 00:00:00 2001
From: zhongtao <taozh97@163.com>
Date: Mon, 17 Oct 2022 20:20:00 +0800
Subject: [PATCH 20/43] improve code in utils_mount_spec
Signed-off-by: zhongtao <taozh97@163.com>
---
src/utils/cutils/utils_mount_spec.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/utils/cutils/utils_mount_spec.c b/src/utils/cutils/utils_mount_spec.c
index d8f64c81..e9b23cf2 100644
--- a/src/utils/cutils/utils_mount_spec.c
+++ b/src/utils/cutils/utils_mount_spec.c
@@ -458,15 +458,23 @@ int util_parse_mount_spec(char *mount_str, mount_spec **spec, char **errmsg_out)
if (mount_str == NULL) {
CACHE_ERRMSG(errmsg, "Invalid mount specification: can't be empty");
- ret = -1;
- goto out;
+ return -1;
}
if (!mount_str[0]) {
CACHE_ERRMSG(errmsg, "Invalid mount specification: can't be empty");
- ret = -1;
- goto out;
+ return -1;
}
+ if(spec == NULL){
+ CACHE_ERRMSG(errmsg, "Invalid spec: can't be NULL");
+ return -1;
+ }
+
+ if(errmsg_out == NULL){
+ CACHE_ERRMSG(errmsg, "Invalid errmsg_out: can't be NULL");
+ return -1;
+ }
+
m = util_common_calloc_s(sizeof(mount_spec));
if (m == NULL) {
CACHE_ERRMSG(errmsg, "out of memory");
--
2.25.1