From: divverent Date: Sun, 9 May 2010 13:08:56 +0000 (+0000) Subject: fix segfault on empty slots in a stringbuffer on buf_sort X-Git-Tag: xonotic-v0.1.0preview~230^2~295 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f2f99c891d575a2982667ef1af876a4e72ca02e3;p=xonotic%2Fdarkplaces.git fix segfault on empty slots in a stringbuffer on buf_sort git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10183 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/prvm_cmds.c b/prvm_cmds.c index f93133e6..a7450c6a 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -4463,8 +4463,8 @@ static int BufStr_SortStringsUP (const void *in1, const void *in2) const char *a, *b; a = *((const char **) in1); b = *((const char **) in2); - if(!a[0]) return 1; - if(!b[0]) return -1; + if(!a || !a[0]) return 1; + if(!b || !b[0]) return -1; return strncmp(a, b, stringbuffers_sortlength); } @@ -4473,8 +4473,8 @@ static int BufStr_SortStringsDOWN (const void *in1, const void *in2) const char *a, *b; a = *((const char **) in1); b = *((const char **) in2); - if(!a[0]) return 1; - if(!b[0]) return -1; + if(!a || !a[0]) return 1; + if(!b || !b[0]) return -1; return strncmp(b, a, stringbuffers_sortlength); }