Fix memory leaks (whoops)

This commit is contained in:
simon 2020-01-11 16:04:53 -05:00
parent d1a2f9b1d5
commit b7f13f425c
6 changed files with 15 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -322,6 +322,8 @@ void parse_media_filename(const char *filepath, document_t *doc) {
int res = avformat_open_input(&pFormatCtx, filepath, NULL, NULL); int res = avformat_open_input(&pFormatCtx, filepath, NULL, NULL);
if (res < 0) { if (res < 0) {
LOG_ERRORF(doc->filepath, "(media.c) avformat_open_input() returned [%d] %s", res, av_err2str(res)) LOG_ERRORF(doc->filepath, "(media.c) avformat_open_input() returned [%d] %s", res, av_err2str(res))
avformat_close_input(&pFormatCtx);
avformat_free_context(pFormatCtx);
return; return;
} }
@ -357,13 +359,22 @@ void parse_media_vfile(struct vfile *f, document_t *doc) {
int res = avformat_open_input(&pFormatCtx, "", NULL, NULL); int res = avformat_open_input(&pFormatCtx, "", NULL, NULL);
if (res == -5) { if (res == -5) {
// Tried to parse media that requires seek // Tried to parse media that requires seek
av_free(io_ctx->buffer);
avio_context_free(&io_ctx);
avformat_close_input(&pFormatCtx);
avformat_free_context(pFormatCtx);
return; return;
} else if (res < 0) { } else if (res < 0) {
LOG_ERRORF(doc->filepath, "(media.c) avformat_open_input() returned [%d] %s", res, av_err2str(res)) LOG_ERRORF(doc->filepath, "(media.c) avformat_open_input() returned [%d] %s", res, av_err2str(res))
av_free(io_ctx->buffer);
avio_context_free(&io_ctx);
avformat_close_input(&pFormatCtx);
avformat_free_context(pFormatCtx);
return; return;
} }
parse_media(pFormatCtx, doc); parse_media(pFormatCtx, doc);
av_free(io_ctx); av_free(io_ctx->buffer);
avio_context_free(&io_ctx);
} }

View File

@ -1193,6 +1193,8 @@ g_hash_table_insert(ext_table, "srt", (gpointer)text_plain);
g_hash_table_insert(ext_table, "nfo", (gpointer)text_plain); g_hash_table_insert(ext_table, "nfo", (gpointer)text_plain);
g_hash_table_insert(ext_table, "sfv", (gpointer)text_plain); g_hash_table_insert(ext_table, "sfv", (gpointer)text_plain);
g_hash_table_insert(ext_table, "m3u", (gpointer)text_plain); g_hash_table_insert(ext_table, "m3u", (gpointer)text_plain);
g_hash_table_insert(ext_table, "csv", (gpointer)text_plain);
g_hash_table_insert(ext_table, "eml", (gpointer)text_plain);
g_hash_table_insert(ext_table, "rt", (gpointer)text_richtext); g_hash_table_insert(ext_table, "rt", (gpointer)text_richtext);
g_hash_table_insert(ext_table, "rtf", (gpointer)text_richtext); g_hash_table_insert(ext_table, "rtf", (gpointer)text_richtext);
g_hash_table_insert(ext_table, "rtx", (gpointer)text_richtext); g_hash_table_insert(ext_table, "rtx", (gpointer)text_richtext);