mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #2764
2764: Prevent NULL pointer in mem_copy (fixes #2753) r=heinrich5991 a=Jupeyy Co-authored-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
commit
297f2764f7
|
@ -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