mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #3657
3657: Don't leak memory on Windows in logger r=heinrich5991 a=def- Thanks to 拓真 on Discord for report <!-- What is the motivation for the changes of this pull request --> ## 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: Vlad <51330274+gerdoe-jr@users.noreply.github.com> Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
9556b4f59a
|
@ -177,10 +177,16 @@ static void logger_stdout_sync(const char *line, void *user)
|
|||
char u16[4] = {0};
|
||||
|
||||
if(codepoint < 0)
|
||||
{
|
||||
free(wide);
|
||||
return;
|
||||
}
|
||||
|
||||
if(str_utf16le_encode(u16, codepoint) != 2)
|
||||
{
|
||||
free(wide);
|
||||
return;
|
||||
}
|
||||
|
||||
mem_copy(&wide[wlen], u16, 2);
|
||||
}
|
||||
|
@ -188,6 +194,7 @@ static void logger_stdout_sync(const char *line, void *user)
|
|||
console = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
WriteConsoleW(console, wide, wlen, NULL, NULL);
|
||||
WriteConsoleA(console, "\n", 1, NULL, NULL);
|
||||
free(wide);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue