From a3b1caf952717fc79a589a870a0caf50538bc76d Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 12 Jun 2021 16:08:22 +0800 Subject: [PATCH] =?UTF-8?q?[example]=20=E8=A7=A3=E5=86=B3=E6=BD=9C?= =?UTF-8?q?=E5=9C=A8=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20=E9=87=8D=E6=96=B0=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81?= =?UTF-8?q?=EF=BC=8C=E6=BA=90=E8=87=AA=EF=BC=9Ahttps://gitee.com/rtthread/?= =?UTF-8?q?rt-thread/pulls/48/files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/file/listdir.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/file/listdir.c b/examples/file/listdir.c index 98fbc5ea2c..06c746a642 100644 --- a/examples/file/listdir.c +++ b/examples/file/listdir.c @@ -13,7 +13,7 @@ void list_dir(const char* path) { - char * fullpath; + char * fullpath = RT_NULL; DIR *dir; dir = opendir(path); @@ -57,7 +57,10 @@ void list_dir(const char* path) rt_kprintf("open %s directory failed\n", path); } - rt_free(fullpath); + if (RT_NULL != fullpath) + { + rt_free(fullpath); + } } #ifdef RT_USING_FINSH @@ -80,6 +83,6 @@ static void cmd_list_dir(int argc, char *argv[]) } 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 /* RT_USING_FINSH */