From 2ee2e56ee0795ed0bea5d0e9bd261010bfaa0d16 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 8 Nov 2018 18:24:25 +0300 Subject: safer implementation of PathToRelative --- src/mir_core/src/path.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mir_core/src/path.cpp b/src/mir_core/src/path.cpp index eb1577748e..dd5e49325f 100644 --- a/src/mir_core/src/path.cpp +++ b/src/mir_core/src/path.cpp @@ -39,8 +39,10 @@ MIR_CORE_DLL(int) PathIsAbsolute(const char *path) MIR_CORE_DLL(int) PathToRelative(const char *pSrc, char *pOut, const char *pBase) { - if (!pSrc || !pSrc[0] || strlen(pSrc) > MAX_PATH) + if (!pSrc || !pSrc[0] || strlen(pSrc) > MAX_PATH) { + *pOut = 0; return 0; + } if (!PathIsAbsolute(pSrc)) strncpy_s(pOut, MAX_PATH, pSrc, _TRUNCATE); -- cgit v1.2.3