[PATCH] SDL_ttf .c

Hello,

I noticed that if you call
TTF_Font * TTF_OpenFont(const char *file, int ptsize);
with an inexisting “file” pathname, then SDL_ttf simply crashes.

Here is the gdb output:
Program received signal SIGSEGV, Segmentation fault.
0x0804ac6b in TTF_OpenFontIndexRW (src=0x0, freesrc=1, ptsize=16, index=0) at
SDL_ttf.c:244
244 position = SDL_RWtell(src);

I found there there where no check that for file existance, then here is the patch.

Can someone patch it official SDL_ttf ?

Luc-Olivier

-------------- next part --------------
A non-text attachment was scrubbed…
Name: SDL_ttf.c.patch
Type: text/x-patch
Size: 376 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040719/b13768c4/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed…
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040719/b13768c4/attachment.pgp

Yeah, that sounds like a pretty nasty bug, and very un-SDL like. I
hope Sam applies the patch.On Mon, 19 Jul 2004 15:55:15 +0200, Nuage wrote:

Hello,

I noticed that if you call
TTF_Font * TTF_OpenFont(const char *file, int ptsize);
with an inexisting “file” pathname, then SDL_ttf simply crashes.

Here is the gdb output:
Program received signal SIGSEGV, Segmentation fault.
0x0804ac6b in TTF_OpenFontIndexRW (src=0x0, freesrc=1, ptsize=16, index=0) at
SDL_ttf.c:244
244 position = SDL_RWtell(src);

I found there there where no check that for file existance, then here is the patch.

Can someone patch it official SDL_ttf ?

Luc-Olivier


Patrick “Diablo-D3” McFarland || @Patrick_McFarland
"Computer games don’t affect kids; I mean if Pac-Man affected us as kids, we’d
all be running around in darkened rooms, munching magic pills and listening to
repetitive electronic music." – Kristian Wilson, Nintendo, Inc, 1989

This is not bug, it is feature.
The NULL is not a filename and as you can read from
http://jcatki.no-ip.org/SDL_ttf/ (when the site is not down)
“NOTE: src is not checked for NULL, so be careful.”

Google cache:
http://66.102.11.104/search?q=cache:ak7g-VA9DPYJ:jcatki.no-ip.org/SDL_ttf/SDL_ttf_15.html+site:jcatki.no-ip.org+TTF_OpenFontRW&hl=enOn Mon, 2004-07-19 at 15:55, Nuage wrote:

Hello,

I noticed that if you call
TTF_Font * TTF_OpenFont(const char *file, int ptsize);
with an inexisting “file” pathname, then SDL_ttf simply crashes.


Ivo Danihelka

I noticed that if you call
TTF_Font * TTF_OpenFont(const char *file, int ptsize);
with an inexisting “file” pathname, then SDL_ttf simply crashes.

This is not bug, it is feature.
The NULL is not a filename and as you can read from
http://jcatki.no-ip.org/SDL_ttf/ (when the site is not down)
“NOTE: src is not checked for NULL, so be careful.”

He didn’t pass NULL to TTF_OpenFont. He passed it a valid filename;
TTF_OpenFontIndexRW received NULL.On Fri, Jul 23, 2004 at 02:20:22AM +0200, Ivo Danihelka wrote:

0x0804ac6b in TTF_OpenFontIndexRW (src=0x0, freesrc=1, ptsize=16, index=0)


Glenn Maynard

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ivo Danihelka wrote:
| On Mon, 2004-07-19 at 15:55, Nuage wrote:
|
|>Hello,
|>
|>I noticed that if you call
|>TTF_Font * TTF_OpenFont(const char *file, int ptsize);
|>with an inexisting “file” pathname, then SDL_ttf simply crashes.
|>
|
|
| This is not bug, it is feature.

(Can’t call a missing check a feature, but it’s not the point.)
It’s written:
"
NOTE: src is not checked for NULL, so be careful.
Returns: a pointer to the font as a TTF_Font. NULL is returned on errors.
"
And when I send a valid filename of an inexisting file, it crash,
instead of returning NULL as specified.

| The NULL is not a filename and as you can read from
| http://jcatki.no-ip.org/SDL_ttf/ (when the site is not down)
| “NOTE: src is not checked for NULL, so be careful.”
|
| Google cache:
|
http://66.102.11.104/search?q=cache:ak7g-VA9DPYJ:jcatki.no-ip.org/SDL_ttf/SDL_ttf_15.html+site:jcatki.no-ip.org+TTF_OpenFontRW&hl=en

Thanks for the google link…
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBAQNDeyAGkzgDVa0RArAHAJwIWU02xifiGFcLKR+Mza3gn+cxJwCdEoQd
MeYBYgDR+iTE0u0bUISzekU=
=JpoI
-----END PGP SIGNATURE-----