diff --git a/src/main.c b/src/main.c index bef16b80..7b50ddcf 100644 --- a/src/main.c +++ b/src/main.c @@ -1289,6 +1289,7 @@ void Program_shutdown(void) { FREE_POINTER(Config.Bookmark_directory[i]); } + FREE_POINTER(Config.Scripts_directory); Uninit_text(); diff --git a/src/readini.c b/src/readini.c index 81adefb2..1885e020 100644 --- a/src/readini.c +++ b/src/readini.c @@ -993,16 +993,19 @@ int Load_INI(T_Config * conf) } // Optional, Location of last directory used for Lua scripts browsing (>=2.3) - conf->Scripts_directory[0]='\0'; + free(conf->Scripts_directory); + conf->Scripts_directory = NULL; if (!Load_INI_get_string (file,buffer,"Scripts_directory",value_label, 1)) { - strcpy(conf->Scripts_directory,value_label); + if (value_label[0] != '\0') + conf->Scripts_directory = strdup(value_label); } - if (conf->Scripts_directory[0]=='\0') + if (conf->Scripts_directory == NULL) { // Default when empty: - Realpath(Data_directory, conf->Scripts_directory); - Append_path(conf->Scripts_directory, SCRIPTS_SUBDIRECTORY, NULL); + char * path = Realpath(Data_directory, NULL); + conf->Scripts_directory = Filepath_append_to_dir(path, SCRIPTS_SUBDIRECTORY); + free(path); } conf->Allow_multi_shortcuts=0; diff --git a/src/struct.h b/src/struct.h index 7e32c354..9de45ee9 100644 --- a/src/struct.h +++ b/src/struct.h @@ -375,7 +375,7 @@ typedef struct byte Sync_views; ///< Boolean, true when the Main and Spare should share their viewport settings. byte Stylus_mode; ///< Boolean, true to tweak some tools (eg:Curve) for single-button stylus. word Swap_buttons; ///< Sets which key swaps mouse buttons : 0=none, or GFX2_MOD_CTRL, or GFX2_MOD_ALT. - char Scripts_directory[MAX_PATH_CHARACTERS];///< Full pathname of directory for Lua scripts + char * Scripts_directory; ///< Full pathname of directory for Lua scripts byte Allow_multi_shortcuts; ///< Boolean, true if the same key combination can trigger multiple shortcuts. byte Tilemap_allow_flipped_x; ///< Boolean, true if the Tilemap tool should detect x-flipped tiles. byte Tilemap_allow_flipped_y; ///< Boolean, true if the Tilemap tool should detect y-flipped tiles.