avformat/utils: avoid void pointer arithmetic

Fixes compliation on MSVC.

Regression since cb708d8703.

Based on code by James Almer.

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint
2026-05-14 20:49:34 +02:00
parent a327bc0561
commit 43bbd6dbf9
3 changed files with 7 additions and 8 deletions
+1 -1
View File
@@ -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)
+2 -3
View File
@@ -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 */
+4 -4
View File
@@ -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;