diff mbox

[FFmpeg-devel] avutil/hwcontext_dxva2: return an error when buffer allocation fails

Message ID 20170917032021.3004-1-jamrial@gmail.com
State Accepted
Commit 18516d3e695980525bd9758dc7b8a8e36cd3f09e
Headers show

Commit Message

James Almer Sept. 17, 2017, 3:20 a.m. UTC
This also prevents the use of an uninitialized variable.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavutil/hwcontext_dxva2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Mark Thompson Sept. 19, 2017, 10:26 p.m. UTC | #1
On 17/09/17 04:20, James Almer wrote:
> This also prevents the use of an uninitialized variable.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavutil/hwcontext_dxva2.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c
> index 6c41788e2e..2ddd4be7b1 100644
> --- a/libavutil/hwcontext_dxva2.c
> +++ b/libavutil/hwcontext_dxva2.c
> @@ -307,8 +307,10 @@ static int dxva2_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *
>      }
>  
>      map = av_mallocz(sizeof(*map));
> -    if (!map)
> +    if (!map) {
> +        err = AVERROR(ENOMEM);
>          goto fail;
> +    }
>  
>      err = ff_hwframe_map_create(src->hw_frames_ctx, dst, src,
>                                  dxva2_unmap_frame, map);
> 

LGTM.

Thanks,

- Mark
James Almer Sept. 19, 2017, 10:33 p.m. UTC | #2
On 9/19/2017 7:26 PM, Mark Thompson wrote:
> On 17/09/17 04:20, James Almer wrote:
>> This also prevents the use of an uninitialized variable.
>>
>> Signed-off-by: James Almer <jamrial@gmail.com>
>> ---
>>  libavutil/hwcontext_dxva2.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c
>> index 6c41788e2e..2ddd4be7b1 100644
>> --- a/libavutil/hwcontext_dxva2.c
>> +++ b/libavutil/hwcontext_dxva2.c
>> @@ -307,8 +307,10 @@ static int dxva2_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *
>>      }
>>  
>>      map = av_mallocz(sizeof(*map));
>> -    if (!map)
>> +    if (!map) {
>> +        err = AVERROR(ENOMEM);
>>          goto fail;
>> +    }
>>  
>>      err = ff_hwframe_map_create(src->hw_frames_ctx, dst, src,
>>                                  dxva2_unmap_frame, map);
>>
> 
> LGTM.
> 
> Thanks,
> 
> - Mark

Pushed.
diff mbox

Patch

diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c
index 6c41788e2e..2ddd4be7b1 100644
--- a/libavutil/hwcontext_dxva2.c
+++ b/libavutil/hwcontext_dxva2.c
@@ -307,8 +307,10 @@  static int dxva2_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *
     }
 
     map = av_mallocz(sizeof(*map));
-    if (!map)
+    if (!map) {
+        err = AVERROR(ENOMEM);
         goto fail;
+    }
 
     err = ff_hwframe_map_create(src->hw_frames_ctx, dst, src,
                                 dxva2_unmap_frame, map);