Segmentaion fault while using SDL_ttf

Hi,

           I am trying to display text message on the screen.The screen size is 640(width) * 480(height).When the text is displayed at the bottom portion (from 420 to 480) there is a problem.After text rendering, when we call SDL_FreeSurface() function there is a segmentation fault.       

The code snippet for Rendering is given below.

            text = TTF_RenderText_Shaded(font,buf,fg,bg);

            SDL_BlitSurface(text,NULL,screen,&rect);

            SDL_UpdateRects(screen,1,&rect);

The debug output using gdb is this.

Program received signal SIGSEGV, Segmentation fault.
SDL_FreeSurface (surface=0x2272616c) at SDL_surface.c:793
793 if ( --surface->refcount > 0 ) {

    Is there any possible way to avoid this segmentation fault.

Best Regards
Krishnan V R

Hi,

           I am trying to display text message on the screen.The screen size is 640(width) * 480(height).When the text is displayed at the bottom portion (from 420 to 480) there is a problem.After text rendering, when we call SDL_FreeSurface() function there is a segmentation fault.       
The code snippet for Rendering is given below.
            text = TTF_RenderText_Shaded(font,buf,fg,bg);
            SDL_BlitSurface(text,NULL,screen,&rect);
            SDL_UpdateRects(screen,1,&rect);
The debug output using gdb is this.

Program received signal SIGSEGV, Segmentation fault.
SDL_FreeSurface (surface=0x2272616c) at SDL_surface.c:793
793 if ( --surface->refcount > 0 ) {

    Is there any possible way to avoid this segmentation fault.

It looks like memory corruption to me. I don’t think “surface” is
a valid pointer. (and I don’t see where it would be called in the
code snippet above) I don’t think your problem is related to SDL_ttf.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment