summaryrefslogtreecommitdiff
path: root/src/qcommon/q_shared.c
diff options
context:
space:
mode:
authorZack Middleton <zturtleman@gmail.com>2013-11-06 22:23:33 -0600
committerTim Angus <tim@ngus.net>2014-06-17 17:43:36 +0100
commit613801cc554b3030aa1ce81a0f5d4ceb81e3ce74 (patch)
tree0f35503edf09a7a9be58818d11fb8e1bbb79f144 /src/qcommon/q_shared.c
parentbeb66bf8c5939ce9ee83bb376508b25751c861e5 (diff)
Fix running if built on OS X 10.9
strncpy with in == out causes signal 6 if built on OS X 10.9. (If built on older OS X versions, the game works on 10.9 though.) It was happening in COM_StripExtension during map load.
Diffstat (limited to 'src/qcommon/q_shared.c')
-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);
}