From cb94a128b27b5b71aa822ff134de9f47a34c8d02 Mon Sep 17 00:00:00 2001 From: huangke11 Date: Mon, 18 Apr 2022 11:50:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huangke11 --- frameworks/config_policy/src/config_policy_utils.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frameworks/config_policy/src/config_policy_utils.c b/frameworks/config_policy/src/config_policy_utils.c index 1205777..1eda18f 100644 --- a/frameworks/config_policy/src/config_policy_utils.c +++ b/frameworks/config_policy/src/config_policy_utils.c @@ -57,9 +57,12 @@ static void GetCfgDirRealPolicyValue(CfgDir *res) #ifndef OHOS_LITE unsigned int len = 0; (void)SystemGetParameter(CUST_KEY_POLICY_LAYER, NULL, &len); - if (len > 0 && (res->realPolicyValue = calloc(len, 1))) { - (void)SystemGetParameter(CUST_KEY_POLICY_LAYER, res->realPolicyValue, &len); - return; + if (len > 0) { + res->realPolicyValue = (char *)calloc(len, sizeof(char)); + if (res->realPolicyValue != NULL) { + (void)SystemGetParameter(CUST_KEY_POLICY_LAYER, res->realPolicyValue, &len); + return; + } } #endif res->realPolicyValue = strdup("/system:/chipset:/sys_prod:/chip_prod"); -- Gitee