From 4449f38c17766a4645fda12dc0f56a79f0ae2bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sat, 18 Nov 2023 23:30:42 +0100 Subject: [PATCH] various: add some missing error checks --- filters/f_autoconvert.c | 3 +++ filters/f_decoder_wrapper.c | 8 ++++++-- filters/f_swresample.c | 2 ++ player/loadfile.c | 2 +- stream/stream_libarchive.c | 2 ++ video/out/gpu/video.c | 5 +++-- video/out/vo_gpu_next.c | 3 +++ 7 files changed, 20 insertions(+), 5 deletions(-) diff --git a/filters/f_autoconvert.c b/filters/f_autoconvert.c index 7f5c054d6f..dcd5ea2485 100644 --- a/filters/f_autoconvert.c +++ b/filters/f_autoconvert.c @@ -165,6 +165,9 @@ static bool build_image_converter(struct mp_autoconvert *c, struct mp_log *log, } struct mp_filter *conv = mp_filter_create(f, &convert_filter); + if (!conv) + return false; + mp_filter_add_pin(conv, MP_PIN_IN, "in"); mp_filter_add_pin(conv, MP_PIN_OUT, "out"); diff --git a/filters/f_decoder_wrapper.c b/filters/f_decoder_wrapper.c index 87489ccdf1..76b97078f5 100644 --- a/filters/f_decoder_wrapper.c +++ b/filters/f_decoder_wrapper.c @@ -430,10 +430,12 @@ static bool reinit_decoder(struct priv *p) } } + if (!driver) + return false; + if (!list) { struct mp_decoder_list *full = talloc_zero(NULL, struct mp_decoder_list); - if (driver) - driver->add_decoders(full); + driver->add_decoders(full); const char *codec = p->codec->codec; if (codec && strcmp(codec, "null") == 0) codec = fallback; @@ -1232,6 +1234,8 @@ struct mp_decoder_wrapper *mp_decoder_wrapper_create(struct mp_filter *parent, p->decf = mp_filter_create(p->dec_root_filter ? p->dec_root_filter : public_f, &decf_filter); + if (!p->decf) + goto error; p->decf->priv = p; p->decf->log = public_f->log = p->log; mp_filter_add_pin(p->decf, MP_PIN_OUT, "out"); diff --git a/filters/f_swresample.c b/filters/f_swresample.c index fb1ef05194..8cb687def0 100644 --- a/filters/f_swresample.c +++ b/filters/f_swresample.c @@ -334,6 +334,8 @@ static bool reorder_planes(struct mp_aframe *mpa, int *reorder, int num_planes = mp_aframe_get_planes(mpa); uint8_t **planes = mp_aframe_get_data_rw(mpa); + if (num_planes && !planes) + return false; uint8_t *old_planes[MP_NUM_CHANNELS]; assert(num_planes <= MP_NUM_CHANNELS); for (int n = 0; n < num_planes; n++) diff --git a/player/loadfile.c b/player/loadfile.c index b7a4e31153..1d25dc340a 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -290,7 +290,7 @@ static void print_stream(struct MPContext *mpctx, struct track *t) APPEND(b, " %dHz", s->codec->samplerate); } APPEND(b, ")"); - if (s->hls_bitrate > 0) + if (s && s->hls_bitrate > 0) APPEND(b, " (%d kbps)", (s->hls_bitrate + 500) / 1000); if (t->is_external) APPEND(b, " (external)"); diff --git a/stream/stream_libarchive.c b/stream/stream_libarchive.c index 61c95cc349..ff2d5123e5 100644 --- a/stream/stream_libarchive.c +++ b/stream/stream_libarchive.c @@ -583,6 +583,8 @@ static int archive_entry_open(stream_t *stream) char *base = talloc_strdup(p, stream->path); char *name = strchr(base, '|'); + if (!name) + return STREAM_ERROR; *name++ = '\0'; if (name[0] == '/') name += 1; diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index 0f48261389..852ee78cde 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -1702,6 +1702,7 @@ static void reinit_scaler(struct gl_video *p, struct scaler *scaler, double scale_factor, int sizes[]) { + assert(conf); if (scaler_conf_eq(scaler->conf, *conf) && scaler->scale_factor == scale_factor && scaler->initialized) @@ -1709,13 +1710,13 @@ static void reinit_scaler(struct gl_video *p, struct scaler *scaler, uninit_scaler(p, scaler); - if (conf && scaler->index == SCALER_DSCALE && (!conf->kernel.name || + if (scaler->index == SCALER_DSCALE && (!conf->kernel.name || !conf->kernel.name[0])) { conf = &p->opts.scaler[SCALER_SCALE]; } - if (conf && scaler->index == SCALER_CSCALE && (!conf->kernel.name || + if (scaler->index == SCALER_CSCALE && (!conf->kernel.name || !conf->kernel.name[0])) { conf = &p->opts.scaler[SCALER_SCALE]; diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index 440a324031..e003f2391f 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -1946,6 +1946,9 @@ static void update_hook_opts(struct priv *p, char **opts, const char *shaderpath break; } + if (!opt.type) + goto next_hook; + opt.type->parse(p->log, &opt, k, v, hp->data); goto next_hook; }