diff mbox series

[FFmpeg-devel,1/2] avformat/hnm: Check for extradata allocation failure

Message ID 20200321063118.6790-1-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/2] avformat/hnm: Check for extradata allocation failure
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt March 21, 2020, 6:31 a.m. UTC
and also add padding to it; moreover, don't use memcpy to write one byte
to extradata.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/hnm.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Paul B Mahol March 21, 2020, 9:21 a.m. UTC | #1
lgtm

On 3/21/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
> and also add padding to it; moreover, don't use memcpy to write one byte
> to extradata.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/hnm.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/hnm.c b/libavformat/hnm.c
> index 40ef5c06ee..31221553a4 100644
> --- a/libavformat/hnm.c
> +++ b/libavformat/hnm.c
> @@ -70,6 +70,7 @@ static int hnm_read_header(AVFormatContext *s)
>      Hnm4DemuxContext *hnm = s->priv_data;
>      AVIOContext *pb = s->pb;
>      AVStream *vst;
> +    int ret;
>
>      /* default context members */
>      hnm->pts = 0;
> @@ -113,10 +114,10 @@ static int hnm_read_header(AVFormatContext *s)
>      vst->codecpar->codec_tag  = 0;
>      vst->codecpar->width      = hnm->width;
>      vst->codecpar->height     = hnm->height;
> -    vst->codecpar->extradata  = av_mallocz(1);
> +    if ((ret = ff_alloc_extradata(vst->codecpar, 1)) < 0)
> +        return ret;
>
> -    vst->codecpar->extradata_size = 1;
> -    memcpy(vst->codecpar->extradata, &hnm->version, 1);
> +    vst->codecpar->extradata[0] = hnm->version;
>
>      vst->start_time = 0;
>
> --
> 2.20.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer March 22, 2020, 12:03 p.m. UTC | #2
On Sat, Mar 21, 2020 at 10:21:02AM +0100, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/hnm.c b/libavformat/hnm.c
index 40ef5c06ee..31221553a4 100644
--- a/libavformat/hnm.c
+++ b/libavformat/hnm.c
@@ -70,6 +70,7 @@  static int hnm_read_header(AVFormatContext *s)
     Hnm4DemuxContext *hnm = s->priv_data;
     AVIOContext *pb = s->pb;
     AVStream *vst;
+    int ret;
 
     /* default context members */
     hnm->pts = 0;
@@ -113,10 +114,10 @@  static int hnm_read_header(AVFormatContext *s)
     vst->codecpar->codec_tag  = 0;
     vst->codecpar->width      = hnm->width;
     vst->codecpar->height     = hnm->height;
-    vst->codecpar->extradata  = av_mallocz(1);
+    if ((ret = ff_alloc_extradata(vst->codecpar, 1)) < 0)
+        return ret;
 
-    vst->codecpar->extradata_size = 1;
-    memcpy(vst->codecpar->extradata, &hnm->version, 1);
+    vst->codecpar->extradata[0] = hnm->version;
 
     vst->start_time = 0;