From: mkver via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: mkver <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avcodec/bsf/noise: Avoid allocation for string (PR #20506)
Date: Fri, 12 Sep 2025 17:58:06 -0000
Message-ID: <175769988724.25.8554154946274968285@463a07221176> (raw)
PR #20506 opened by mkver
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20506
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20506.patch
>From 77afa9f560fb883d543184911192acf918ea9b9c Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Fri, 12 Sep 2025 19:34:39 +0200
Subject: [PATCH] avcodec/bsf/noise: Avoid allocation for string
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/bsf/noise.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/libavcodec/bsf/noise.c b/libavcodec/bsf/noise.c
index a622855717..3462b30f82 100644
--- a/libavcodec/bsf/noise.c
+++ b/libavcodec/bsf/noise.c
@@ -18,13 +18,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <stdlib.h>
+#include <stddef.h>
#include "bsf.h"
#include "bsf_internal.h"
#include "libavutil/log.h"
-#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/eval.h"
@@ -79,24 +78,22 @@ typedef struct NoiseContext {
static int noise_init(AVBSFContext *ctx)
{
NoiseContext *s = ctx->priv_data;
+ const char *amount_str = s->amount_str;
int ret;
- if (!s->amount_str) {
- s->amount_str = (!s->drop_str && !s->dropamount) ? av_strdup("-1") : av_strdup("0");
- if (!s->amount_str)
- return AVERROR(ENOMEM);
- }
+ if (!amount_str)
+ amount_str = (!s->drop_str && !s->dropamount) ? "-1" : "0";
if (ctx->par_in->codec_id == AV_CODEC_ID_WRAPPED_AVFRAME &&
- strcmp(s->amount_str, "0")) {
+ strcmp(amount_str, "0")) {
av_log(ctx, AV_LOG_ERROR, "Wrapped AVFrame noising is unsupported\n");
return AVERROR_PATCHWELCOME;
}
- ret = av_expr_parse(&s->amount_pexpr, s->amount_str,
+ ret = av_expr_parse(&s->amount_pexpr, amount_str,
var_names, NULL, NULL, NULL, NULL, 0, ctx);
if (ret < 0) {
- av_log(ctx, AV_LOG_ERROR, "Error in parsing expr for amount: %s\n", s->amount_str);
+ av_log(ctx, AV_LOG_ERROR, "Error in parsing expr for amount: %s\n", amount_str);
return ret;
}
--
2.49.1
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2025-09-12 17:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=175769988724.25.8554154946274968285@463a07221176 \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git