[FFmpeg-devel,1/5] examples/filtering_video: fix memory leak

Submitted by Zhao Zhili on May 14, 2018, 12:17 p.m.

Details

Message ID 20180514121802.14519-1-quinkblack@foxmail.com
State New
Headers show

Commit Message

Zhao Zhili May 14, 2018, 12:17 p.m.
From: Zhao Zhili <wantlamy@gmail.com>

---
 doc/examples/filtering_video.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Zhao Zhili May 17, 2018, 5:52 a.m.
On 2018年05月14日 20:17, Zhao Zhili wrote:
> From: Zhao Zhili <wantlamy@gmail.com>
>
> ---
>   doc/examples/filtering_video.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c
> index 38ff9bb..225dccc 100644
> --- a/doc/examples/filtering_video.c
> +++ b/doc/examples/filtering_video.c
> @@ -233,6 +233,7 @@ int main(int argc, char **argv)
>   
>           if (packet.stream_index == video_stream_index) {
>               ret = avcodec_send_packet(dec_ctx, &packet);
> +            av_packet_unref(&packet);
>               if (ret < 0) {
>                   av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n");
>                   break;
> @@ -269,8 +270,9 @@ int main(int argc, char **argv)
>                       av_frame_unref(frame);
>                   }
>               }
> +        } else {
> +            av_packet_unref(&packet);
>           }
> -        av_packet_unref(&packet);
>       }
>   end:
>       avfilter_graph_free(&filter_graph);

Ping for review.

Patch hide | download patch | download mbox

diff --git a/doc/examples/filtering_video.c b/doc/examples/filtering_video.c
index 38ff9bb..225dccc 100644
--- a/doc/examples/filtering_video.c
+++ b/doc/examples/filtering_video.c
@@ -233,6 +233,7 @@  int main(int argc, char **argv)
 
         if (packet.stream_index == video_stream_index) {
             ret = avcodec_send_packet(dec_ctx, &packet);
+            av_packet_unref(&packet);
             if (ret < 0) {
                 av_log(NULL, AV_LOG_ERROR, "Error while sending a packet to the decoder\n");
                 break;
@@ -269,8 +270,9 @@  int main(int argc, char **argv)
                     av_frame_unref(frame);
                 }
             }
+        } else {
+            av_packet_unref(&packet);
         }
-        av_packet_unref(&packet);
     }
 end:
     avfilter_graph_free(&filter_graph);