This is an automated email from the git hooks/post-receive script.
Git pushed a commit to branch master
in repository ffmpeg.
The following commit(s) were added to refs/heads/master by this push:
new 43bbd6dbf9 avformat/utils: avoid void pointer arithmetic
43bbd6dbf9 is described below
commit 43bbd6dbf993d44ecd93417c2c3804bf8682755c
Author: Marton Balint <[email protected]>
AuthorDate: Thu May 14 20:49:34 2026 +0200
Commit: Marton Balint <[email protected]>
CommitDate: Thu May 14 20:52:45 2026 +0200
avformat/utils: avoid void pointer arithmetic
Fixes compliation on MSVC.
Regression since cb708d8703a9f72730a1bc07638a435e1381c841.
Based on code by James Almer.
Signed-off-by: Marton Balint <[email protected]>
---
libavformat/hlsenc.c | 2 +-
libavformat/internal.h | 5 ++---
libavformat/utils.c | 8 ++++----
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 132cd353ed..59a173988b 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1099,7 +1099,7 @@ static int hls_append_segment(struct AVFormatContext *s,
HLSContext *hls,
av_bprint_chars(&bp, 0, 1);
}
- en = ff_bprint_finalize_as_fam(&bp, &en0, sizeof(en0), en0.buf);
+ en = ff_bprint_finalize_as_fam(&bp, &en0, offsetof(HLSSegment, buf));
if (!en)
return AVERROR(ENOMEM);
#define NEXT(s) ((s) + strlen(s) + 1)
diff --git a/libavformat/internal.h b/libavformat/internal.h
index b3a0a0c2d5..bd3aa24cf5 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -706,11 +706,10 @@ int ff_make_codec_str(void *logctx, const
AVCodecParameters *par,
*
* @param bp pointer to an AVBprint struct
* @param struct_ptr pointer to the struct to be copied
- * @param struct_size must be sizeof(*struct_ptr)
- * @param flex_member must be struct_ptr->flexible_array_member
+ * @param fam_offset must be offsetof(StructType, flexible_array_member)
* @return pointer to the newly allocated struct, NULL on allocation error or
* if the AVBPrint buffer is not complete
*/
-void *ff_bprint_finalize_as_fam(struct AVBPrint *bp, const void *struct_ptr,
size_t struct_size, void *flex_member);
+void *ff_bprint_finalize_as_fam(struct AVBPrint *bp, const void *struct_ptr,
size_t fam_offset);
#endif /* AVFORMAT_INTERNAL_H */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 0192dba97f..5f00d86bc5 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -685,20 +685,20 @@ int ff_parse_opts_from_query_string(void *obj, const char
*str, int allow_unknow
return 0;
}
-void *ff_bprint_finalize_as_fam(struct AVBPrint *bp, const void *struct_ptr,
size_t struct_size, void *flex_member)
+void *ff_bprint_finalize_as_fam(struct AVBPrint *bp, const void *struct_ptr,
size_t fam_offset)
{
if (!av_bprint_is_complete(bp)) {
av_bprint_finalize(bp, NULL);
return NULL;
}
- void *p = av_malloc(struct_size + bp->len);
+ uint8_t *p = av_malloc(fam_offset + bp->len);
if (!p) {
av_bprint_finalize(bp, NULL);
return NULL;
}
- memcpy(p, struct_ptr, struct_size);
- memcpy(p + (flex_member - struct_ptr), bp->str, bp->len);
+ memcpy(p, struct_ptr, fam_offset);
+ memcpy(p + fam_offset, bp->str, bp->len);
av_bprint_finalize(bp, NULL);
return p;
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]