mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #3532
3532: Fix crash on namechange (fixes #3444) r=heinrich5991 a=def- <!-- What is the motivation for the changes of this pull request --> ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [x] Tested in combination with possibly related configuration options - [x] Written a unit test if it works standalone, system.c especially - [x] Considered possible null pointers and out of bounds array indexing - [x] Changed no physics that affect existing maps - [x] 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: def <dennis@felsin9.de>
This commit is contained in:
commit
7f4ec45e9a
|
@ -631,7 +631,7 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS
|
|||
if(Text)
|
||||
{
|
||||
int Offset = str_length(pStr);
|
||||
int CharsLeft = StrSize - Offset - 1;
|
||||
int CharsLeft = StrSize - Offset;
|
||||
char *pCur = pStr + Offset;
|
||||
str_utf8_copy(pCur, Text, CharsLeft);
|
||||
for(int i = 0; i < CharsLeft; i++)
|
||||
|
|
|
@ -217,6 +217,8 @@ TEST(Str, StrCopyNum)
|
|||
EXPECT_STREQ(aBuf, "Foobar");
|
||||
str_utf8_truncate(aBuf, sizeof(aBuf), foo, 7);
|
||||
EXPECT_STREQ(aBuf, "Foobaré");
|
||||
str_utf8_truncate(aBuf, sizeof(aBuf), foo, 0);
|
||||
EXPECT_STREQ(aBuf, "");
|
||||
|
||||
char aBuf2[8];
|
||||
str_utf8_truncate(aBuf2, sizeof(aBuf2), foo, 7);
|
||||
|
|
|
@ -79,4 +79,5 @@ TEST(Thread, Lock)
|
|||
void *pThread = thread_init(LockThread, &Lock, "lock");
|
||||
lock_unlock(Lock);
|
||||
thread_wait(pThread);
|
||||
lock_destroy(Lock);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue