]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix segfault on empty slots in a stringbuffer on buf_sort
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 9 May 2010 13:08:56 +0000 (13:08 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 9 May 2010 13:08:56 +0000 (13:08 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10183 d7cf8633-e32d-0410-b094-e92efae38249

prvm_cmds.c

index f93133e6bfe06fd6a9aa957229315d23f09e7bce..a7450c6a2d20d4387f3babb896bdc9caa311a882 100644 (file)
@@ -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);
 }