From: John Hodge Date: Fri, 22 Oct 2010 06:29:48 +0000 (+0800) Subject: Fixing places where malloc() (and others) is not null checked X-Git-Tag: rel0.06~8 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=fd042bf66c507e2263492d45b9bad62e1706a4bd;p=tpg%2Facess2.git Fixing places where malloc() (and others) is not null checked --- 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);