Explorar o código

【修复】示例代码内存泄露

Signed-off-by: chenyong <1521761801@qq.com>
chenyong %!s(int64=6) %!d(string=hai) anos
pai
achega
10ece6296d
Modificáronse 2 ficheiros con 12 adicións e 2 borrados
  1. 6 1
      samples/webclient_get_sample.c
  2. 6 1
      samples/webclient_post_sample.c

+ 6 - 1
samples/webclient_get_sample.c

@@ -197,7 +197,12 @@ int webclient_get_test(int argc, char **argv)
         return -RT_ERROR;
     }
 
-    return 0;
+    if (uri)
+    {
+        web_free(uri);
+    }
+    
+    return RT_EOK;
 }
 
 #ifdef FINSH_USING_MSH

+ 6 - 1
samples/webclient_post_sample.c

@@ -181,8 +181,13 @@ int webclient_post_test(int argc, char **argv)
         rt_kprintf("web_post_test -s [uri]  - webclient simplify post request test.\n");
         return -RT_ERROR;
     }
+    
+    if (uri)
+    {
+        web_free(uri);
+    }
 
-    return 0;
+    return RT_EOK;
 }