From: 孙春阳 Date: Mon, 13 Oct 2025 06:55:03 +0000 (+0800) Subject: 修复无配置时,configmodel读取乱码问题 X-Git-Tag: V1.0.9_20251128_194606_LN~250^2~10^2 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=a635fc3a23f690d6089324e3cd7e91b4f5943a8d;p=mirrors%2FFD230.git 修复无配置时,configmodel读取乱码问题 --- diff --git a/code/sdk/zhihui/config/src/ConfigModel.cpp b/code/sdk/zhihui/config/src/ConfigModel.cpp index a23dcf2e2..e1231aa2a 100644 --- a/code/sdk/zhihui/config/src/ConfigModel.cpp +++ b/code/sdk/zhihui/config/src/ConfigModel.cpp @@ -109,6 +109,7 @@ namespace OHOS { char* stringtmp=(char*)malloc(MAX_STRING_DATA_LEN); if (stringtmp == NULL) return "-2"; + memset(stringtmp,0,MAX_STRING_DATA_LEN); int value_len = UtilsGetValue(field_name,stringtmp,MAX_STRING_DATA_LEN); if (value_len<0) { @@ -133,6 +134,7 @@ namespace OHOS char *buf = (char*)malloc(MAX_NUM_BUF_LEN); if (buf == NULL) return 0.0f; + memset(buf,0,MAX_NUM_BUF_LEN); int value_len = UtilsGetValue(field_name,buf,MAX_NUM_BUF_LEN); if (value_len<0) { @@ -169,6 +171,7 @@ namespace OHOS { char *buf = (char*)malloc(MAX_NUM_BUF_LEN); if (buf == NULL) return 0; + memset(buf,0,MAX_NUM_BUF_LEN); int value_len = UtilsGetValue(field_name,buf,MAX_NUM_BUF_LEN); if (value_len<0) { @@ -205,6 +208,7 @@ namespace OHOS { char *buf = (char*)malloc(MAX_NUM_BUF_LEN); if (buf == NULL) return false; + memset(buf,0,MAX_NUM_BUF_LEN); int value_len = UtilsGetValue(field_name,buf,MAX_NUM_BUF_LEN); CONFIG_DEBUG("ReadKVData_Bool %s = %s (%d)\n",field_name,buf,value_len); if (value_len<0)