Commit 3b08e046 authored by Andreas Rheinhardt's avatar Andreas Rheinhardt

avcodec/alsdec, mlz: Check allocation

Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
parent e925d545
...@@ -2111,7 +2111,9 @@ static av_cold int decode_init(AVCodecContext *avctx) ...@@ -2111,7 +2111,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
ff_mlz_init_dict(avctx, ctx->mlz); ret = ff_mlz_init_dict(avctx, ctx->mlz);
if (ret < 0)
return ret;
ff_mlz_flush_dict(ctx->mlz); ff_mlz_flush_dict(ctx->mlz);
for (c = 0; c < avctx->channels; ++c) { for (c = 0; c < avctx->channels; ++c) {
......
...@@ -20,8 +20,11 @@ ...@@ -20,8 +20,11 @@
#include "mlz.h" #include "mlz.h"
av_cold void ff_mlz_init_dict(void* context, MLZ *mlz) { av_cold int ff_mlz_init_dict(void *context, MLZ *mlz)
{
mlz->dict = av_mallocz(TABLE_SIZE * sizeof(*mlz->dict)); mlz->dict = av_mallocz(TABLE_SIZE * sizeof(*mlz->dict));
if (!mlz->dict)
return AVERROR(ENOMEM);
mlz->flush_code = FLUSH_CODE; mlz->flush_code = FLUSH_CODE;
mlz->current_dic_index_max = DIC_INDEX_INIT; mlz->current_dic_index_max = DIC_INDEX_INIT;
...@@ -30,6 +33,8 @@ av_cold void ff_mlz_init_dict(void* context, MLZ *mlz) { ...@@ -30,6 +33,8 @@ av_cold void ff_mlz_init_dict(void* context, MLZ *mlz) {
mlz->next_code = FIRST_CODE; mlz->next_code = FIRST_CODE;
mlz->freeze_flag = 0; mlz->freeze_flag = 0;
mlz->context = context; mlz->context = context;
return 0;
} }
av_cold void ff_mlz_flush_dict(MLZ *mlz) { av_cold void ff_mlz_flush_dict(MLZ *mlz) {
......
...@@ -57,7 +57,7 @@ typedef struct MLZ { ...@@ -57,7 +57,7 @@ typedef struct MLZ {
/** Initialize the dictionary /** Initialize the dictionary
*/ */
void ff_mlz_init_dict(void* context, MLZ *mlz); int ff_mlz_init_dict(void *context, MLZ *mlz);
/** Flush the dictionary /** Flush the dictionary
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment