From: hcj_ <1224667075@qq.com> Date: Thu, 16 May 2024 23:57:20 +0000 (+0800) Subject: 修改读取通讯录时的异常判断(2) X-Git-Tag: release_V1.2.70_20241020_135402~1113^2 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=refs%2Fchanges%2F176%2Ftarget%2F1;p=mirrors%2FFD230.git 修改读取通讯录时的异常判断(2) --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp b/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp index 39d49f1a2..67f0af0f2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp @@ -172,6 +172,13 @@ namespace OHOS char* buf = (char *)malloc(512); int ret=fread(buf,1,512,fp); + if(ret==0) + { + printf("文件为空\r\n"); + free(buf); + return; + } + int offset_f=512; while (ret==512) { @@ -186,6 +193,7 @@ namespace OHOS num=0; addressbook_t.num=0; printf("异常全部清除\r\n"); + free(buf); return; } printf("人数: %d\r\n",num);