Skip to content

Commit

Permalink
Move jpeg_finish_compress out of destructor (#433)
Browse files Browse the repository at this point in the history
* Move jpeg_finish_compress out of destr

Moving the function out will ensure
that no function that can error will
be called inside a destructor, thus
leaving no chance to get two exceptions
in flight or finishing compression even
if an error occured

* Comments and minor stylistical changes

Added comments to explain why finish
compress was moved out of destructor,
and did stylistical changes
  • Loading branch information
simmplecoder authored Feb 19, 2020
1 parent 2ff00f6 commit e684f96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/boost/gil/extension/io/jpeg/detail/write.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class writer< Device
, 1
);
}

jpeg_finish_compress ( this->get() );
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ struct writer_backend< Device

~writer_backend()
{
jpeg_finish_compress ( get() );
// JPEG compression object destruction does not signal errors,
// unlike jpeg_finish_compress called elsewhere,
// so there is no need for the setjmp bookmark here.
jpeg_destroy_compress( get() );
}

Expand Down

0 comments on commit e684f96

Please sign in to comment.