diff --git a/.gitignore b/.gitignore index b629c7d4..745daf8d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ lite *.lha release_files *.o +*.snalyzerinfo diff --git a/README_Amiga.md b/README_Amiga.md index 3b49d784..10def8ad 100644 --- a/README_Amiga.md +++ b/README_Amiga.md @@ -195,6 +195,10 @@ https://git.walkero.gr/walkero/lite-xl/issues # Changelog +## [2.0.3r3] - future +### Fixed +- Fixed non existing path crashes on OS4 + ## [2.0.3r2] - 2022-06-18 ### Added - First public MorphOS version released diff --git a/src/platform/amigaos4.c b/src/platform/amigaos4.c index fd53bd2f..e3af2af5 100644 --- a/src/platform/amigaos4.c +++ b/src/platform/amigaos4.c @@ -5,30 +5,29 @@ #include "amigaos4.h" -static char *getFullPath(const char *path) +static BOOL getFullPath(const char *path, char *result) { - char *appPath = malloc(sizeof(char) * MAX_DOS_NAME); BPTR pathLock = Lock(path, SHARED_LOCK); if (pathLock) { - NameFromLock(pathLock, appPath, sizeof(char) * MAX_DOS_NAME); + NameFromLock(pathLock, result, sizeof(char) * MAX_DOS_NAME); UnLock(pathLock); - return appPath; + return TRUE; } - return NULL; + + return FALSE; } -static char *getCurrentPath(void) +static BOOL getCurrentPath(char *result) { - char *appPath = malloc(sizeof(char) * MAX_DOS_NAME); BPTR pathLock = GetCurrentDir(); if (pathLock) { - NameFromLock(pathLock, appPath, sizeof(char) * MAX_DOS_NAME); - return appPath; + NameFromLock(pathLock, result, sizeof(char) * MAX_DOS_NAME); + return TRUE; } - return NULL; + return FALSE; } char *_fullpath(const char *path) @@ -46,16 +45,25 @@ char *_fullpath(const char *path) if (!strcmp(path, "./lite")) { // TODO: Add code to get the name of the executable - strcpy(result, getFullPath("PROGDIR:lite")); - return result; + if (getFullPath("PROGDIR:lite", result)) + { + return result; + } } if (!strcmp(path, ".")) { - strcpy(result, getCurrentPath()); - return result; + if(getCurrentPath(result)) + { + return result; + } } - strcpy(result, getFullPath(path)); - return result; + if (getFullPath(path, result)) + { + return result; + } + + return NULL; } +