We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4376

Summary: Add some robustness to SDL_ttf
Product: SDL_ttf Reporter: Sylvain <sylvain.becker>
Component: miscAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: unspecified   
Hardware: x86_64   
OS: Linux   
Attachments: patch

Description Sylvain 2018-11-10 13:53:50 UTC
Add some robustness that would make crash SDL_ttf if it received bad datas.
(though I never got such case, probably FreeType filters it).

Those should not be strictly negative:
  underline_top_row 
  strikethrough_top_row
  cached->maxx - cached->minx
  cached->maxy - cached->miny

Avoid also potential division by 0 with italic  (.../font->height).

Change some printf() by SDL_Log()
Comment 1 Sylvain 2018-11-10 13:55:34 UTC
Created attachment 3483 [details]
patch
Comment 2 Sylvain 2018-11-10 14:01:01 UTC
BTW since it touches the SDL_ceilf(glyph_italic...) :

There was a commit 
"SDL_ttf uses SDL_ceilf(), which is in SDL 2.0.8 "
https://hg.libsdl.org/SDL_ttf/rev/c763e38e7dfd

There is only one call to SDL_ceilf()
We could prevent to update the dependency by not using SDL_ceilf, 
and by using fixed point arithmetic there. Let me know if I can provide a patch.
Comment 3 Sam Lantinga 2018-11-13 01:07:44 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL_ttf/rev/50fb59da9a0e

Updating the SDL dependency is fine, thanks though!