| Summary: | TTF_RenderUNICODE_Blended segmentation fault | ||
|---|---|---|---|
| Product: | SDL_ttf | Reporter: | Davide Prade <davide.prade> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | blocker | ||
| Priority: | P2 | CC: | sylvain.becker |
| Version: | 2.0.15 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 10 | ||
| Attachments: | Font used | ||
you would need to check with latest SDL2_ttf code because it has changed I am using the last available on MSYS2.
$ pacman -Ss SDL2_ttf
mingw64/mingw-w64-x86_64-SDL2_ttf 2.0.15-1 [installed]
A library that allows you to use TrueType fonts in your SDL applications (Version 2) (mingw-w64)
Commenting on calls to "SDL_FreeSurface" works.
Created attachment 3817 [details]
Font used
The crash happens also with null terminated strings and also with other fonts.
const Uint16 txt1[] = {'P', 'u', 's', 'h', ' ', 'U', 'p', ' ', '1', '\0'};
const Uint16 txt2[] = {'P', 'u', 's', 'h', ' ', 'U', 'p', ' ', '2', '\0'};
|
The following code generates a segmentation fault on the marked line. I compile on MSYS2 MinGW 64 bit: - mingw64/mingw-w64-x86_64-SDL2 2.0.9-1 - mingw64/mingw-w64-x86_64-SDL2_ttf --------------------------- Thread 1 received signal SIGSEGV, Segmentation fault. 0x000000006c7c6100 in ?? () from D:\Repositories\Git\solari-gt3\SDL2.dll (gdb) bt #0 0x000000006c7c6100 in ?? () from SDL2.dll #1 0x000000006c7c9d03 in ?? () from SDL2.dll #2 0x0000000071003922 in ?? () from SDL2_ttf.dll #3 0x0000000071003e24 in ?? () from SDL2_ttf.dll #4 0x0000000000450e61 in main (argc=1, argv=0x5c74390) at test.cpp:100 --------------------------- --------------------------- if (TTF_Init() != 0) { fprintf(stderr, "Couldn't initialize TTF library"); } else { TTF_Font *font = TTF_OpenFont("arialbd.ttf", 26); if (font != NULL) { SDL_Color col = {255, 255, 255, 255}; const Uint16 txt1[] = {'P', 'u', 's', 'h', ' ', 'U', 'p', ' ', '1'}; SDL_Surface *surf1 = TTF_RenderUNICODE_Blended(font, txt1, col); SDL_FreeSurface(surf1); surf1 = NULL; const Uint16 txt2[] = {'P', 'u', 's', 'h', ' ', 'U', 'p', ' ', '2'}; /*SEGFAULT*/SDL_Surface *surf2 = TTF_RenderUNICODE_Blended(font, txt2, col); SDL_FreeSurface(surf2); surf2 = NULL; TTF_CloseFont(font); font = NULL; } else { fprintf(stderr, "Couldn't open font"); } } ---------------------------