From fb0eacff9b571381d6a69c5914b754da39e63bc9 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Mon, 4 Apr 2016 15:38:51 +0200 Subject: [PATCH] add av_dict_free, fix memleak Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/a830d0d58714a0fd59272cdcad8930182b1511ef Author: Jacek Jendrzej Date: 2016-04-04 (Mon, 04 Apr 2016) --- src/driver/record.cpp | 4 ++++ src/driver/streamts.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/driver/record.cpp b/src/driver/record.cpp index 04e3871b2..6a15e4775 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -2083,8 +2083,12 @@ bool CStreamRec::Open(CZapitChannel * channel) if (avformat_open_input(&ifcx, url.c_str(), NULL, &options) != 0) { printf("%s: Cannot open input [%s]!\n", __FUNCTION__, url.c_str()); + if (!headers.empty()) + av_dict_free(&options); return false; } + if (!headers.empty()) + av_dict_free(&options); if (avformat_find_stream_info(ifcx, NULL) < 0) { printf("%s: Cannot find stream info [%s]!\n", __FUNCTION__, channel->getUrl().c_str()); diff --git a/src/driver/streamts.cpp b/src/driver/streamts.cpp index b1740bfd1..2ab401258 100644 --- a/src/driver/streamts.cpp +++ b/src/driver/streamts.cpp @@ -788,8 +788,12 @@ bool CStreamStream::Open() av_dict_set(&options, "headers", headers.c_str(), 0); if (avformat_open_input(&ifcx, url.c_str(), NULL, &options) != 0) { printf("%s: Cannot open input [%s]!\n", __FUNCTION__, channel->getUrl().c_str()); + if (!headers.empty()) + av_dict_free(&options); return false; } + if (!headers.empty()) + av_dict_free(&options); if (avformat_find_stream_info(ifcx, NULL) < 0) { printf("%s: Cannot find stream info [%s]!\n", __FUNCTION__, channel->getUrl().c_str());