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.
This commit is contained in:
Zack Middleton 2013-11-06 22:23:33 -06:00
parent 7672533e8f
commit fd4cd6612d

View file

@ -76,8 +76,12 @@ COM_StripExtension
void COM_StripExtension( const char *in, char *out, int destsize ) void COM_StripExtension( const char *in, char *out, int destsize )
{ {
const char *dot = strrchr(in, '.'), *slash; const char *dot = strrchr(in, '.'), *slash;
if (dot && (!(slash = strrchr(in, '/')) || slash < dot)) 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 else
Q_strncpyz(out, in, destsize); Q_strncpyz(out, in, destsize);
} }