Potential crash if parser->finish returns an error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PowerWyrm
    Prophet
    • Apr 2008
    • 2986

    Potential crash if parser->finish returns an error

    For each parser, run_parser() is called to do the parsing. However at the end, there is:

    r = fp->finish(p);
    if (r) print_error(fp, p);

    Problem is: in 99% of the cases, each "finish" method calls parser_destroy() on the parser, which calls mem_free() to free the memory associated with the parser. Calling then print_error() on a freed pointer will result in a crash.

    I've looked at all parser_destroy() calls and found the following where the "finish" method doesn't return 0:
    - obj-init.c: finish_parse_slay(), finish_parse_brand(), finish_parse_curse()
    - ui-visuals.c: visuals_file_parser_finish()
    PWMAngband variant maintainer - check https://github.com/draconisPW/PWMAngband (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
Working...
😀
😂
🥰
😘
🤢
😎
😞
😡
👍
👎