diff --git a/components/dfs/src/dfs.c b/components/dfs/src/dfs.c index bcef0973b342b45be4d3a12ad895beb3a3b753ee..fc4d4f847bfecc4a25f00bdff47b7ad7d9e80fcc 100644 --- a/components/dfs/src/dfs.c +++ b/components/dfs/src/dfs.c @@ -304,6 +304,9 @@ char *dfs_normalize_path(const char *directory, const char *filename) { fullpath = rt_malloc(strlen(directory) + strlen(filename) + 2); + if (fullpath == RT_NULL) + return RT_NULL; + /* join path and file name */ rt_snprintf(fullpath, strlen(directory) + strlen(filename) + 2, "%s/%s", directory, filename); @@ -311,6 +314,9 @@ char *dfs_normalize_path(const char *directory, const char *filename) else { fullpath = rt_strdup(filename); /* copy string */ + + if (fullpath == RT_NULL) + return RT_NULL; } src = fullpath;