Skip to content

Commit

Permalink
Fix some minor memorly leaks for mjpeg
Browse files Browse the repository at this point in the history
Relates to #262

Signed-off-by: Evan Flynn <[email protected]>
  • Loading branch information
flynneva committed Aug 22, 2023
1 parent a0fb199 commit da715c9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions include/usb_cam/formats/mjpeg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ class MJPEG2RGB : public pixel_format_base

~MJPEG2RGB()
{
if (m_averror_str) {
free(m_averror_str);
}
if (m_avoptions) {
free(m_avoptions);
}
if (m_avpacket) {
free(m_avpacket);
}
if (m_avcodec_context) {
avcodec_close(m_avcodec_context);
avcodec_free_context(&m_avcodec_context);
Expand All @@ -155,10 +164,6 @@ class MJPEG2RGB : public pixel_format_base
if (m_avframe_rgb) {
av_frame_free(&m_avframe_rgb);
}
if (m_avpacket) {
av_packet_unref(m_avpacket);
av_packet_free(&m_avpacket);
}
if (m_avparser) {
av_parser_close(m_avparser);
}
Expand Down

0 comments on commit da715c9

Please sign in to comment.