Fixed crash regarding memory leak

This commit is contained in:
AlexBratosin2001 2016-12-30 19:11:33 +02:00
parent fd01232a26
commit cc7692d7eb

View File

@ -276,6 +276,15 @@ struct lib_cc_decode *update_decoder_list(struct lib_ccx_ctx *ctx)
if (!dec_ctx)
fatal(EXIT_NOT_ENOUGH_MEMORY, "update_decoder_list: init_cc_decode failed. Not enough memory.\n");
list_add_tail( &(dec_ctx->list), &(ctx->dec_ctx_head) );
//DVB related
dec_ctx->prev = NULL;
dec_ctx->dec_sub.prev = NULL;
if (dec_ctx->codec == CCX_CODEC_DVB)
{
dec_ctx->prev = malloc(sizeof(struct lib_cc_decode));
dec_ctx->dec_sub.prev = malloc(sizeof(struct cc_subtitle));
}
}
return dec_ctx;
}
@ -311,6 +320,15 @@ struct lib_cc_decode *update_decoder_list_cinfo(struct lib_ccx_ctx *ctx, struct
if (!dec_ctx)
fatal(EXIT_NOT_ENOUGH_MEMORY, "update_decoder_list_cinfo: Not enough memory allocating dec_ctx (multiprogram == false)\n");
list_add_tail( &(dec_ctx->list), &(ctx->dec_ctx_head) );
//DVB related
dec_ctx->prev = NULL;
dec_ctx->dec_sub.prev = NULL;
if (dec_ctx->codec == CCX_CODEC_DVB)
{
dec_ctx->prev = malloc(sizeof(struct lib_cc_decode));
dec_ctx->dec_sub.prev = malloc(sizeof(struct cc_subtitle));
}
}
}
else
@ -320,16 +338,6 @@ struct lib_cc_decode *update_decoder_list_cinfo(struct lib_ccx_ctx *ctx, struct
fatal(EXIT_NOT_ENOUGH_MEMORY, "update_decoder_list_cinfo: Not enough memory allocating dec_ctx ((multiprogram == true)\n");
list_add_tail( &(dec_ctx->list), &(ctx->dec_ctx_head) );
}
if (cinfo)
{
dec_ctx->prev = NULL;
dec_ctx->dec_sub.prev = NULL;
if (cinfo->codec == CCX_CODEC_DVB)
{
dec_ctx->prev = malloc(sizeof(struct lib_cc_decode));
dec_ctx->dec_sub.prev = malloc(sizeof(struct cc_subtitle));
}
}
return dec_ctx;
}
@ -388,6 +396,17 @@ struct encoder_ctx *update_encoder_list_cinfo(struct lib_ccx_ctx *ctx, struct ca
if (!enc_ctx)
return NULL;
list_add_tail( &(enc_ctx->list), &(ctx->enc_ctx_head) );
// DVB related
enc_ctx->prev = NULL;
if (cinfo)
{
if (cinfo->codec == CCX_CODEC_DVB)
{
enc_ctx->write_previous = 0;
enc_ctx->prev = malloc(sizeof(struct encoder_ctx));
}
}
}
}
else
@ -418,15 +437,6 @@ struct encoder_ctx *update_encoder_list_cinfo(struct lib_ccx_ctx *ctx, struct ca
freep(&ccx_options.enc_cfg.output_filename);
}
freep(&extension);
if (cinfo)
{
enc_ctx->prev = NULL;
if (cinfo->codec == CCX_CODEC_DVB)
{
enc_ctx->write_previous = 0;
enc_ctx->prev = malloc(sizeof(struct encoder_ctx));
}
}
return enc_ctx;
}