From 615f2490f1592c5d1683f3e8967aab692724012e Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 27 Sep 2009 16:57:19 +0800 Subject: [PATCH] Debug --- Kernel/vfs/open.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Kernel/vfs/open.c b/Kernel/vfs/open.c index e075fb7b..7b651322 100644 --- a/Kernel/vfs/open.c +++ b/Kernel/vfs/open.c @@ -51,6 +51,10 @@ char *VFS_GetAbsPath(char *Path) // Memory File if(Path[0] == '$') { ret = malloc(strlen(Path)+1); + if(!ret) { + Warning("VFS_GetAbsPath - malloc() returned NULL"); + return NULL; + } strcpy(ret, Path); LEAVE('p', ret); return ret; @@ -59,6 +63,10 @@ char *VFS_GetAbsPath(char *Path) // Check if the path is already absolute if(Path[0] == '/') { ret = malloc(pathLen + 1); + if(!ret) { + Warning("VFS_GetAbsPath - malloc() returned NULL"); + return NULL; + } strcpy(ret, Path); baseLen = 1; } else { @@ -506,14 +514,21 @@ int VFS_ChDir(char *New) // Create Absolute buf = VFS_GetAbsPath(New); - if(buf == NULL) return -1; + if(buf == NULL) { + Log("VFS_ChDir: Path expansion failed"); + return -1; + } // Check if path is valid node = VFS_ParsePath(buf, NULL); - if(!node) return -1; + if(!node) { + Log("VFS_ChDir: Path is invalid"); + return -1; + } // Check if is a directory if( !(node->Flags & VFS_FFLAG_DIRECTORY) ) { + Log("VFS_ChDir: Not a directory"); if(node->Close) node->Close(node); return -1; } -- 2.20.1