diff --git a/services/param/adapter/param_selinux.c b/services/param/adapter/param_selinux.c index 1425690e1..139bfabc0 100755 --- a/services/param/adapter/param_selinux.c +++ b/services/param/adapter/param_selinux.c @@ -70,6 +70,8 @@ static int LoadParamLabels(const char *fileName, SecurityLabelFunc label, void * FILE *fp = fopen(fileName, "r"); PARAM_CHECK(fp != NULL, return -1, "Open file %s fail", fileName); SubStringInfo *info = malloc(sizeof(SubStringInfo) * (SUBSTR_INFO_DAC + 1)); + PARAM_CHECK(info != NULL, (void)fclose(fp); + return -1, "Failed to malloc for %s", fileName); char buff[PARAM_BUFFER_SIZE]; int infoCount = 0; ParamAuditData auditData = {}; diff --git a/services/param/manager/param_utils.c b/services/param/manager/param_utils.c index 50350d2bf..7b1070cc6 100755 --- a/services/param/manager/param_utils.c +++ b/services/param/manager/param_utils.c @@ -71,6 +71,7 @@ int ReadFileInDir(const char *dirPath, const char *includeExt, processFile(fileName, context); } } + free(fileName); closedir(pDir); return 0; } diff --git a/services/src/init_signal_handler.c b/services/src/init_signal_handler.c index da625eeeb..81fdf4201 100644 --- a/services/src/init_signal_handler.c +++ b/services/src/init_signal_handler.c @@ -27,7 +27,6 @@ #include "init_service_manager.h" #ifndef OHOS_LITE -#include "init_param.h" #include "uv.h" #endif