From 0f112d6f19ecf6e7d443eaf3464ebf916048be59 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Thu, 28 Dec 2017 08:37:09 +0100 Subject: [PATCH] Avoid a crash in "script list" (#521) This command crashes if the path to the executable directory could not be found. --- client/cmdscript.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/cmdscript.c b/client/cmdscript.c index 23163aa9..0d19f496 100644 --- a/client/cmdscript.c +++ b/client/cmdscript.c @@ -76,8 +76,11 @@ int CmdList(const char *Cmd) { DIR *dp; struct dirent *ep; - char script_directory_path[strlen(get_my_executable_directory()) + strlen(LUA_SCRIPTS_DIRECTORY) + 1]; - strcpy(script_directory_path, get_my_executable_directory()); + char const * exedir = get_my_executable_directory(); + if (exedir == NULL) + return 0; + char script_directory_path[strlen(exedir) + strlen(LUA_SCRIPTS_DIRECTORY) + 1]; + strcpy(script_directory_path, exedir); strcat(script_directory_path, LUA_SCRIPTS_DIRECTORY); dp = opendir(script_directory_path); -- 2.39.5