mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Prevent NULL pointer in mem_copy (fixes #2753)
This commit is contained in:
parent
ef9260601e
commit
aed4293040
|
@ -3223,8 +3223,11 @@ const char *str_next_token(const char *str, const char *delim, char *buffer, int
|
|||
{
|
||||
int len = 0;
|
||||
const char *tok = str_token_get(str, delim, &len);
|
||||
if(len < 0)
|
||||
if(len < 0 || tok == NULL)
|
||||
{
|
||||
buffer[0] = '\0';
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = buffer_size > len ? len : buffer_size - 1;
|
||||
mem_copy(buffer, tok, len);
|
||||
|
|
|
@ -173,6 +173,7 @@ TEST(Str, InList)
|
|||
EXPECT_FALSE(str_in_list("", ",", "xyz"));
|
||||
|
||||
EXPECT_TRUE(str_in_list("FOO,,BAR", ",", ""));
|
||||
EXPECT_TRUE(str_in_list("abc,,def", ",", "def"));
|
||||
}
|
||||
|
||||
TEST(Str, StrFormat)
|
||||
|
|
Loading…
Reference in a new issue