From fd4cd6612d2c3be0ff604d64cc96d72eba2c4427 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Wed, 6 Nov 2013 22:23:33 -0600 Subject: [PATCH] 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. --- code/qcommon/q_shared.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/qcommon/q_shared.c b/code/qcommon/q_shared.c index 357451c5..690838cc 100644 --- a/code/qcommon/q_shared.c +++ b/code/qcommon/q_shared.c @@ -76,8 +76,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); }