3813: Only sort friends, if you got any r=def- a=Jupeyy

as TsFreddie pointed out, it asserts inside the array function back(), bcs the list is empty.

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Jupeyy <jupjopjap@gmail.com>
Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2021-05-06 13:40:09 +00:00 committed by GitHub
commit 70f79bf3bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View file

@ -2203,6 +2203,7 @@ if(GTEST_FOUND OR DOWNLOAD_GTEST)
netaddr.cpp
packer.cpp
prng.cpp
sorted_array.cpp
str.cpp
strip_path_and_extension.cpp
teehistorian.cpp

View file

@ -38,7 +38,8 @@ public:
void sort_range()
{
sort(all());
if(parent::size() > 0)
sort(all());
}
/*

View file

@ -0,0 +1,9 @@
#include <gtest/gtest.h>
#include <base/tl/sorted_array.h>
TEST(SortedArray, SortEmptyRange)
{
sorted_array<int> x;
x.sort_range();
}