| Summary: | File is not getting Close in TTF_OpenFontIndexRW. | ||
|---|---|---|---|
| Product: | SDL_ttf | Reporter: | Nitz <nitin.j4> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 2.0.11 | ||
| Hardware: | x86 | ||
| OS: | Linux | ||
Fixed, thanks! http://hg.libsdl.org/SDL_ttf/rev/ef14fbc2201c (In reply to comment #1) > Fixed, thanks! > http://hg.libsdl.org/SDL_ttf/rev/ef14fbc2201c Mr.Sam kindly apply patch here also: /* Check to make sure we can seek in this stream */ position = SDL_RWtell(src); if ( position < 0 ) { TTF_SetError( "Can't seek in stream" ); if ( freesrc ) { SDL_RWclose( src ); } return NULL; } Thanks and Regards Nitz Whoops, good catch. Fixed, thanks! Hi Mr.Sam
The same patch should be applied here also, like this
/* Check to make sure we can seek in this stream */
position = SDL_RWtell(src);
if ( position < 0 ) {
TTF_SetError( "Can't seek in stream" );
if ( freesrc ) {
SDL_RWclose( src );
}
return NULL;
}
This is not applied yet, I think it was missed :)
It looks like it's fixed to me, did I miss something? http://hg.libsdl.org/SDL_ttf/rev/e716077c97c5 I double checked, and this is fixed. |
Hi Mr.Sam, Actually i am using SDL_ttf for some application. While going through the code i found that: In TTF_OpenFontIndexRW( SDL_RWops *src, int freesrc, int ptsize, long nFontIndex ) function when if( ! TTF_initialized ) condition gets true, code just set error and return NULL but file is still open, there is no handling to close the file in this condition which causes crash in the code. Inside this if( ! TTF_initialized )condition there should be some function call also for closing the file i.e SDL_RWclose. Earlier the code is in SDL_ttf-2.0.11 ver. TTF_Font* TTF_OpenFontIndexRW( SDL_RWops *src, int freesrc, int ptsize, long nFontIndex ) { TTF_Font* font; FT_Error error; FT_Face face; FT_Fixed scale; FT_Stream stream; int position; if ( ! TTF_initialized ) { TTF_SetError( "Library not initialized" ); return NULL; } //Some code } Fix should be Like this TTF_Font* TTF_OpenFontIndexRW( SDL_RWops *src, int freesrc, int ptsize, long nFontIndex ) { TTF_Font* font; FT_Error error; FT_Face face; FT_Fixed scale; FT_Stream stream; int position; if ( ! TTF_initialized ) { SDL_RWclose(src); TTF_SetError( "Library not initialized" ); return NULL; } //Some code } Thanks for your support. Best Regards, NITZ