1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avutil/detection_bbox: use offsetof for bboxes_offset

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
This commit is contained in:
Limin Wang 2021-09-25 09:31:17 +08:00
parent f059b56195
commit e724004fd8

View File

@ -21,10 +21,11 @@
AVDetectionBBoxHeader *av_detection_bbox_alloc(uint32_t nb_bboxes, size_t *out_size)
{
size_t size;
struct {
struct BBoxContext {
AVDetectionBBoxHeader header;
AVDetectionBBox boxes[1];
} *ret;
const size_t bboxes_offset = offsetof(struct BBoxContext, boxes);
size = sizeof(*ret);
if (nb_bboxes - 1 > (SIZE_MAX - size) / sizeof(*ret->boxes))
@ -37,7 +38,7 @@ AVDetectionBBoxHeader *av_detection_bbox_alloc(uint32_t nb_bboxes, size_t *out_s
ret->header.nb_bboxes = nb_bboxes;
ret->header.bbox_size = sizeof(*ret->boxes);
ret->header.bboxes_offset = (char *)&ret->boxes - (char *)&ret->header;
ret->header.bboxes_offset = bboxes_offset;
if (out_size)
*out_size = size;