From fd042bf66c507e2263492d45b9bad62e1706a4bd Mon Sep 17 00:00:00 2001
From: John Hodge <tpg@mutabah.net>
Date: Fri, 22 Oct 2010 14:29:48 +0800
Subject: [PATCH] Fixing places where malloc() (and others) is not null checked

---
 Kernel/lib.c      | 1 +
 Kernel/vfs/open.c | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/Kernel/lib.c b/Kernel/lib.c
index d388050a..4fa226c1 100644
--- a/Kernel/lib.c
+++ b/Kernel/lib.c
@@ -459,6 +459,7 @@ char *strdup(const char *Str)
 {
 	char	*ret;
 	ret = malloc(strlen(Str)+1);
+	if( !ret )	return NULL;
 	strcpy(ret, Str);
 	return ret;
 }
diff --git a/Kernel/vfs/open.c b/Kernel/vfs/open.c
index bd43a5f3..5420b33a 100644
--- a/Kernel/vfs/open.c
+++ b/Kernel/vfs/open.c
@@ -458,6 +458,10 @@ int VFS_Open(char *Path, Uint Mode)
 	
 	// Get absolute path
 	absPath = VFS_GetAbsPath(Path);
+	if(absPath == NULL) {
+		Log_Warning("VFS", "VFS_Open: Path expansion failed '%s'", Path);
+		return -1;
+	}
 	LOG("absPath = \"%s\"", absPath);
 	// Parse path and get mount point
 	node = VFS_ParsePath(absPath, NULL);
-- 
GitLab