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

@ -66,7 +66,7 @@ void read_part(opcContainer *c, dyn_buffer_t *buf, opcPart part, document_t *doc
mce_start_element(&reader, NULL, NULL) {
dump_text(&reader, buf);
} mce_end_element(&reader);
}mce_end_document(&reader);
} mce_end_document(&reader);
mceTextReaderCleanup(&reader);
}

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);
if (res < 0) {
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;
}
@ -357,13 +359,22 @@ void parse_media_vfile(struct vfile *f, document_t *doc) {
int res = avformat_open_input(&pFormatCtx, "", NULL, NULL);
if (res == -5) {
// 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;
} else if (res < 0) {
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;
}
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, "sfv", (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, "rtf", (gpointer)text_richtext);
g_hash_table_insert(ext_table, "rtx", (gpointer)text_richtext);