修改读取通讯录时的异常判断(2) 175/1 175/head 176/target/1
authorhcj_ <1224667075@qq.com>
Thu, 16 May 2024 23:57:20 +0000 (07:57 +0800)
committerhcj_ <1224667075@qq.com>
Thu, 16 May 2024 23:57:20 +0000 (07:57 +0800)
code/sdk/application/wearable/fd230app/nativeui/phone/src/phoneaddressmodel.cpp

index 39d49f1..67f0af0 100644 (file)
@@ -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);