From cc3b86ea80cd402cfd4d1751d5710a9257e6f480 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Tue, 10 Mar 2015 18:57:28 -0700 Subject: [PATCH 1/3] Throw an error if DirExists called with empty path. --- core/logic/smn_filesystem.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/logic/smn_filesystem.cpp b/core/logic/smn_filesystem.cpp index 5f69f74e..63348c47 100644 --- a/core/logic/smn_filesystem.cpp +++ b/core/logic/smn_filesystem.cpp @@ -616,7 +616,12 @@ static cell_t sm_DirExists(IPluginContext *pContext, const cell_t *params) { char *name; pContext->LocalToString(params[1], &name); - + + if (!name[0]) + { + return pContext->ThrowNativeError("Invalid path. An empty path string is not valid, use "." to refer to the current working directory."); + } + if (params[0] >= 2 && params[2] == 1) { char *pathID; From 28870d2ae51b468af3a50a539affbb10d0dbf645 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Tue, 10 Mar 2015 18:58:00 -0700 Subject: [PATCH 2/3] Make OpenDirectory error for empty path match error in DirExists. --- core/logic/smn_filesystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/logic/smn_filesystem.cpp b/core/logic/smn_filesystem.cpp index 63348c47..5165fc64 100644 --- a/core/logic/smn_filesystem.cpp +++ b/core/logic/smn_filesystem.cpp @@ -309,7 +309,7 @@ static cell_t sm_OpenDirectory(IPluginContext *pContext, const cell_t *params) if (!path[0]) { - return pContext->ThrowNativeError("Invalid file path"); + return pContext->ThrowNativeError("Invalid path. An empty path string is not valid, use \".\" to refer to the current working directory."); } Handle_t handle = 0; From 7b56dd5c8a2deb72ce450049b2f84545ed1d6d5f Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 22 Mar 2015 19:23:58 -0400 Subject: [PATCH 3/3] Fix build. --- core/logic/smn_filesystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/logic/smn_filesystem.cpp b/core/logic/smn_filesystem.cpp index 5165fc64..6581f2e9 100644 --- a/core/logic/smn_filesystem.cpp +++ b/core/logic/smn_filesystem.cpp @@ -619,7 +619,7 @@ static cell_t sm_DirExists(IPluginContext *pContext, const cell_t *params) if (!name[0]) { - return pContext->ThrowNativeError("Invalid path. An empty path string is not valid, use "." to refer to the current working directory."); + return pContext->ThrowNativeError("Invalid path. An empty path string is not valid, use \".\" to refer to the current working directory."); } if (params[0] >= 2 && params[2] == 1)