> -----Original Message----- > From: myp...@gmail.com <myp...@gmail.com> > Sent: 2021年4月14日 9:29 > To: FFmpeg development discussions and patches > <ffmpeg-devel@ffmpeg.org> > Cc: Guo, Yejun <yejun....@intel.com> > Subject: Re: [FFmpeg-devel] [PATCH V8 1/3] lavu: add side data > AV_FRAME_DATA_DETECTION_BBOXES for object detection/classification > > On Tue, Apr 13, 2021 at 1:26 PM Guo, Yejun <yejun....@intel.com> wrote: > > > > --- > > doc/APIchanges | 2 + > > libavutil/Makefile | 2 + > > libavutil/detection_bbox.c | 73 +++++++++++++++++++++++++ > > libavutil/detection_bbox.h | 107 > +++++++++++++++++++++++++++++++++++++ > > + > > +#include "detection_bbox.h" > > + > > +AVDetectionBBoxHeader *av_detection_bbox_alloc(uint32_t nb_bboxes, > size_t *out_size) > > +{ > > + size_t size; > > + struct { > > + AVDetectionBBoxHeader header; > > + AVDetectionBBox boxes[1]; > > + } *ret; > > + > > + size = sizeof(*ret); > > + if (nb_bboxes - 1 > (SIZE_MAX - size) / sizeof(*ret->boxes)) > > + return NULL; > > + size += sizeof(*ret->boxes) * (nb_bboxes - 1); > > + > > + ret = av_mallocz(size); > > + if (!ret) > > + return NULL; > > + > > + ret->header.nb_bboxes = nb_bboxes; > > + ret->header.bbox_size = sizeof(*ret->boxes); > > + ret->header.bboxes_offset = (char *)&ret->boxes - (char > *)&ret->header; > > + > > + if (out_size) > > + *out_size = size; > > + > > + return &ret->header; > > +} > > + > > +AVDetectionBBoxHeader > *av_detection_bbox_create_side_data(AVFrame *frame, uint32_t > nb_bboxes) > > +{ > > + AVBufferRef *buf; > > + AVDetectionBBoxHeader *header; > > + size_t size; > > + > > + header = av_detection_bbox_alloc(nb_bboxes, &size); > > + if (!header) > > + return NULL; > > + if (size > INT_MAX) { > I think need to use SIZE_MAX, not INT_MAX in this case
thanks for the review, I think 'size_t size' could not larger than SIZE_MAX. actually, the check is referenced from video_enc_params. btw, this check will be removed after the bump, see more at http://ffmpeg.org/pipermail/ffmpeg-devel/2021-April/278779.html _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".