meag
-
2018-08-01
- status: open --> closed-fixed
at: c5fa88692bd9aae9ac3c275051ada9251b17b62b
Pasting text into ezquake leaks the string every time. Allocation backtrace in OS X:
shell> MallocStackLogging=1 ./ezquake-darwin &
shell> leaks ezquake-darwin
Leak: 0x7f8e81d9fad0 size=16 zone: DefaultMallocZone_0x105628000 "TextPasted"
Call stack: [thread 0x7fff79ffb310]:
| start
| main sys_posix.c:319
| Host_Frame host.c:436
| CL_Frame cl_main.c:2433
| Sys_SendKeyEvents vid_sdl2.c:209
| IN_Frame vid_sdl2.c:323
| Key_EventEx keys.c:2154
| Key_Console keys.c:1244
| Sys_GetClipboardTextW sys_sdl2.c:38
| Cocoa_GetClipboardText
| strdup
| malloc
| malloc_zone_malloc
Looks like SDL_GetClipboardText() needs to be SDL_free'd.
In fact, str2wcs returns a pointer to a local array. That isn't safe at all =(.