Menu

#112 load_txt_font crashes

closed
nobody
None
5
2012-10-09
2007-12-02
No

When omitting the end of the glyph interval in the text file load_txt_font causes a segmentation fault. Content of font.txt:
prop_font_orig.bmp 0x20

Code:

include <allegro.h></allegro.h>

int main(void)
{
FONT *f;
if (allegro_init() != 0) return 1;
if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) != 0) return 1;
f = load_txt_font("font.txt", NULL , NULL);
return 0;
}
END_OF_MAIN()

Adding the end code 0xff in font.txt makes it load correctly and it also draws the glyphs in the entire interval correctly

Allegro 4.2.2
Ubuntu 7.04

Discussion

  • Christer Sandberg

    Logged In: YES
    user_id=713645
    Originator: YES

    Strange. So what does
    "the script:
    ...
    dingbats.fnt 0x1000
    would import ... the entire contents of dingbats.fnt starting at Unicode position 0x1000."
    mean if it does not mean that you can omit the end glyph if you want to load the entire contents?

     
  • Elias Pschernig

    Elias Pschernig - 2007-12-06

    Logged In: YES
    user_id=32894
    Originator: NO

    Ah, I see. So to fix it, it should just use as many characters as it can find after the given one.

     
  • Christer Sandberg

    Logged In: YES
    user_id=713645
    Originator: YES

    Attached patch should fixes the crash, and also fixes that leaving out the end glyph crashes. Also fixes another missing check for NULL in the same loop, and replaces an _AL_FREE with destroy_font(), as well as adjusting bad indentation.
    File Added: fonttxt.diff

     
  • Christer Sandberg

     
  • Milan Mimica

    Milan Mimica - 2008-01-22

    Logged In: YES
    user_id=1171214
    Originator: NO

    Thanks! Committed the patch to 4.3.10+ branch on SVN.

     

Log in to post a comment.

MongoDB Logo MongoDB