提交 a3b1caf9 编写于 作者: mysterywolf's avatar mysterywolf

[example] 解决潜在内存泄漏问题

重新解决冲突,源自:https://gitee.com/rtthread/rt-thread/pulls/48/files
上级 5c8625c8
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
void list_dir(const char* path) void list_dir(const char* path)
{ {
char * fullpath; char * fullpath = RT_NULL;
DIR *dir; DIR *dir;
dir = opendir(path); dir = opendir(path);
...@@ -57,7 +57,10 @@ void list_dir(const char* path) ...@@ -57,7 +57,10 @@ void list_dir(const char* path)
rt_kprintf("open %s directory failed\n", path); rt_kprintf("open %s directory failed\n", path);
} }
rt_free(fullpath); if (RT_NULL != fullpath)
{
rt_free(fullpath);
}
} }
#ifdef RT_USING_FINSH #ifdef RT_USING_FINSH
...@@ -80,6 +83,6 @@ static void cmd_list_dir(int argc, char *argv[]) ...@@ -80,6 +83,6 @@ static void cmd_list_dir(int argc, char *argv[])
} }
list_dir(filename); list_dir(filename);
} }
FINSH_FUNCTION_EXPORT_ALIAS(cmd_list_dir, __cmd_list_dir, list directory); MSH_CMD_EXPORT_ALIAS(cmd_list_dir, list_dir, list directory);
#endif /* FINSH_USING_MSH */ #endif /* FINSH_USING_MSH */
#endif /* RT_USING_FINSH */ #endif /* RT_USING_FINSH */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册