2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2025-01-19 06:40:06 +01:00

public: workaround when empty string is passed to COM_ExtractFilePath (should make safe COM_ExtractFilePath)

This commit is contained in:
Alibek Omarov 2023-10-27 08:38:20 +03:00
parent 78bc177e05
commit fe407fbe00

View File

@ -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) == '/' ))