Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTF_Render*_Shaded invalid read #52

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed

TTF_Render*_Shaded invalid read #52

SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 2.0.12
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2014-08-18 20:45:26 +0000, Joshua Landau wrote:

When using the Hans Kendrick font with SDL2_ttf;

#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>

// Very shortened for demo purposes
int main () {
    if (SDL_Init(SDL_INIT_VIDEO) != 0) { return 1; }
    if (TTF_Init() == -1) { return 1; }

    TTF_Font *font = TTF_OpenFont("font.ttf", 28);

    if (font == NULL) { return 1; }

    SDL_Color blank = {0, 0, 0, 0};
    SDL_Color colour = {0, 0, 0, 0};

    TTF_RenderUTF8_Shaded(font, "Y", colour, blank);
}

valgrind reports an error;

==18109== Invalid read of size 1
==18109==    at 0x535812C: TTF_RenderUTF8_Shaded (in /usr/lib/libSDL2_ttf-2.0.so.0.10.2)
==18109==    by 0x40080B: main (in /home/joshua/fontbug/test)
==18109==  Address 0xd9aaf4f is 1 bytes before a block of size 560 alloc'd
==18109==    at 0x4C28730: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18109==    by 0x4ED91FB: ??? (in /usr/lib/libSDL2-2.0.so.0.2.1)
==18109==    by 0x5357F00: TTF_RenderUTF8_Shaded (in /usr/lib/libSDL2_ttf-2.0.so.0.10.2)
==18109==    by 0x40080B: main (in /home/joshua/fontbug/test)

and some systems crash. This depends on the characters (strings with a space at the front have never had this problem) and possibly the font size.


This is pretty much copied verbatim from my Stack Overflow post on the same issue:

http://stackoverflow.com/questions/25369043/ttf-renderutf8-shaded-invalid-read?noredirect=1#comment39563751_25369043

On 2014-08-20 04:21:53 +0000, Sam Lantinga wrote:

Thanks for the bug report. If the font is freely available, can you post a link to it, or attach it to this bug?

Can you rebuild SDL_ttf with debug symbols so you can get line number information?

Does it happen with the latest version from Mercurial?

On 2014-09-05 07:22:36 +0000, Joshua Landau wrote:

This doesn't happen with the latest SDL2_ttf from Mercurial and I no longer need a solution, so I doubt much needs following up on.

I guess I'll probably revisit this in a year or so to check.

FWIW, the font is available here:
http://openfontlibrary.org/en/font/hans-kendrick

On 2017-09-10 06:03:29 +0000, Sam Lantinga wrote:

It sounds like this has been fixed.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant