summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qcommon/q_shared.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/qcommon/q_shared.c b/src/qcommon/q_shared.c
index e70cd398..2c5d76d1 100644
--- a/src/qcommon/q_shared.c
+++ b/src/qcommon/q_shared.c
@@ -77,8 +77,12 @@ COM_StripExtension
void COM_StripExtension( const char *in, char *out, int destsize )
{
const char *dot = strrchr(in, '.'), *slash;
+
if (dot && (!(slash = strrchr(in, '/')) || slash < dot))
- Q_strncpyz(out, in, (destsize < dot-in+1 ? destsize : dot-in+1));
+ destsize = (destsize < dot-in+1 ? destsize : dot-in+1);
+
+ if ( in == out && destsize > 1 )
+ out[destsize-1] = '\0';
else
Q_strncpyz(out, in, destsize);
}