From fe407fbe009955a6961712b2b6eb76bcc1f69d06 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 27 Oct 2023 08:38:20 +0300 Subject: [PATCH] public: workaround when empty string is passed to COM_ExtractFilePath (should make safe COM_ExtractFilePath) --- public/crtlib.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/crtlib.c b/public/crtlib.c index a5565122..6004b59b 100644 --- a/public/crtlib.c +++ b/public/crtlib.c @@ -642,7 +642,14 @@ COM_ExtractFilePath */ void COM_ExtractFilePath( const char *path, char *dest ) { - const char *src = path + Q_strlen( path ) - 1; + size_t len = Q_strlen( path ); + const char *src = path + len - 1; + + if( len == 0 ) + { + dest[0] = 0; + return; + } // back up until a \ or the start while( src != path && !(*(src - 1) == '\\' || *(src - 1) == '/' ))