Browse Source

dfs.c: fix null pointer bug.

geniusgogo 12 years ago
parent
commit
ec6f9e3b5a
1 changed files with 6 additions and 0 deletions
  1. 6 0
      components/dfs/src/dfs.c

+ 6 - 0
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);
         fullpath = rt_malloc(strlen(directory) + strlen(filename) + 2);
 
 
+        if (fullpath == RT_NULL)
+            return RT_NULL;
+
         /* join path and file name */
         /* join path and file name */
         rt_snprintf(fullpath, strlen(directory) + strlen(filename) + 2, 
         rt_snprintf(fullpath, strlen(directory) + strlen(filename) + 2, 
             "%s/%s", directory, filename);
             "%s/%s", directory, filename);
@@ -311,6 +314,9 @@ char *dfs_normalize_path(const char *directory, const char *filename)
     else
     else
     {
     {
         fullpath = rt_strdup(filename); /* copy string */
         fullpath = rt_strdup(filename); /* copy string */
+        
+        if (fullpath == RT_NULL)
+            return RT_NULL;
     }
     }
 
 
     src = fullpath;
     src = fullpath;