Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset generic animation type to BM_TYPE_NONE if APNG processing fails. #1363

Merged

Conversation

MageKing17
Copy link
Member

Prior to APNG support, a regular non-animated PNG could be used as a still-frame command briefing animation. This started causing a crash when APNG support was added because any PNGs sent through generic_anim_stream() would get ga->type set to BM_TYPE_PNG, then sent through the APNG code... which would determine that they weren't APNGs, throw an ApngException, and generic_anim_stream() would return -1... except that BM_TYPE_PNG would still be set, so that when it later came time to render the still frame in generic_frame_render(), it would be sent through generic_anim_render_variable_frame_delay()... which expected a fully-formed APNG, tried to dereference ga->png.anim, and crashed.

This commit is a simple fix to reset ga->type to BM_TYPE_NONE if APNG processing fails, allowing the still-frame PNG to go through generic_anim_render_fixed_frame_delay(), the code path it used to take, and allowing it to display properly instead of crashing.

A more complicated solution might be to change how still frames get processed entirely.

Prior to APNG support, a regular non-animated PNG could be used as a still-frame command briefing animation. This started causing a crash when APNG support was added because any PNGs sent through generic_anim_stream() would get ga->type set to BM_TYPE_PNG, then sent through the APNG code... which would determine that they weren't APNGs, throw an ApngException, and generic_anim_stream() would return -1... except that BM_TYPE_PNG would still be set, so that when it later came time to render the still frame in generic_frame_render(), it would be sent through generic_anim_render_variable_frame_delay()... which expected a fully-formed APNG, tried to dereference ga->png.anim, and crashed.

This commit is a simple fix to reset ga->type to BM_TYPE_NONE if APNG processing fails, allowing the still-frame PNG to go through generic_anim_render_fixed_frame_delay(), the code path it used to take, and allowing it to display properly instead of crashing.
@MageKing17 MageKing17 added fix A fix for bugs, not-a-bugs, and/or regressions. regression A bug introduced by a new feature that breaks something which used to work. labels Jun 4, 2017
@asarium asarium merged commit ec3313f into scp-fs2open:master Jun 4, 2017
@MageKing17 MageKing17 deleted the bugfix/generic-anim-static-png branch June 4, 2017 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix A fix for bugs, not-a-bugs, and/or regressions. regression A bug introduced by a new feature that breaks something which used to work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants