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 - Add some robustness to SDL_ttf
Summary: Add some robustness to SDL_ttf
Status: RESOLVED FIXED
Alias: None
Product: SDL_ttf
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-10 13:53 UTC by Sylvain
Modified: 2018-11-13 01:07 UTC (History)
0 users

See Also:


Attachments
patch (4.22 KB, patch)
2018-11-10 13:55 UTC, Sylvain
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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!