]> gitweb.michael.orlitzky.com - libsvgtiny.git/commit
src/svgtiny.c: improve select_ctx cleanup and error handling
authorMichael Orlitzky <michael@orlitzky.com>
Tue, 22 Oct 2024 11:39:50 +0000 (07:39 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Tue, 22 Oct 2024 12:06:44 +0000 (08:06 -0400)
commit6645b3e57f22801d8725fa5d5c3f003465b1e4e5
treea998470e091e75e42dd7a28be0f2559ec2c69da3
parentedc36f5ff3122f012f3112a65ccb75956548c9e0
src/svgtiny.c: improve select_ctx cleanup and error handling

In the "cleanup:" routine of svgtiny_parse(), we make a few
improvements:

  * The sheets are now removed from the context before destroying
    them. This avoids a potential issue where destroying the context
    itself (which we do afterwards) might try to access the sheets.

  * If we fail to obtain a pointer to a sheet, we stop processing that
    sheet. This should not happen, and if something extremely weird
    happens it can hide the problem, but that's still better than the
    segfault we'd get from trying to operate on an invalid pointer.

  * The sheets are now removed/destroyed in reverse order, last-in
    first-out.
src/svgtiny.c