From ca7c8d7691d8d3f59287747436ef1237f23c73ad Mon Sep 17 00:00:00 2001 From: CodeCodon Date: Sun, 26 Jul 2015 17:24:14 -0500 Subject: [PATCH] use PATH_MAX --- engine/shared/library/sharedFoundation/src/linux/Os.cpp | 4 +++- engine/shared/library/sharedFoundation/src/linux/Os.h | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/engine/shared/library/sharedFoundation/src/linux/Os.cpp b/engine/shared/library/sharedFoundation/src/linux/Os.cpp index e9f2b621..689957f3 100644 --- a/engine/shared/library/sharedFoundation/src/linux/Os.cpp +++ b/engine/shared/library/sharedFoundation/src/linux/Os.cpp @@ -349,8 +349,10 @@ bool Os::getAbsolutePath(const char *relativePath, char *absolutePath, int absol { // realpath sucks and could cause a buffer overrun. however, it's better than writing it ourselves for now. char *result = realpath(relativePath, absolutePath); - if (!result) + if (!result){ + free(result); return false; + } FATAL(istrlen(absolutePath)+1 > absolutePathBufferSize, ("buffer overrun")); return true; diff --git a/engine/shared/library/sharedFoundation/src/linux/Os.h b/engine/shared/library/sharedFoundation/src/linux/Os.h index 44778b4e..972a93b7 100644 --- a/engine/shared/library/sharedFoundation/src/linux/Os.h +++ b/engine/shared/library/sharedFoundation/src/linux/Os.h @@ -27,7 +27,11 @@ public: enum { +#ifdef PATH_MAX + MAX_PATH_LENGTH = PATH_MAX+1 +#else MAX_PATH_LENGTH = 512 +#endif }; typedef void (*QueueCharacterHookFunction)(int keyboard, int character);