diff mbox series

[FFmpeg-devel,01/17] avcodec/dxva2: Initialize dxva_size and check it

Message ID 20240526235230.2876318-1-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,01/17] avcodec/dxva2: Initialize dxva_size and check it | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer May 26, 2024, 11:52 p.m. UTC
Fixes: CID1591878 Uninitialized scalar variable
Fixes: CID1591928 Uninitialized pointer read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/dxva2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer May 26, 2024, 11:56 p.m. UTC | #1
On Mon, May 27, 2024 at 01:52:13AM +0200, Michael Niedermayer wrote:
> Fixes: CID1591878 Uninitialized scalar variable
> Fixes: CID1591928 Uninitialized pointer read
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/dxva2.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Also all the dshow, windows, dxva ... stuff is untested due to lack of a box with such OS
so the respective patches should be reviewed with that in mind!

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 6eb66c02e40..75ca84d0fe0 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -806,7 +806,7 @@  int ff_dxva2_commit_buffer(AVCodecContext *avctx,
                            unsigned type, const void *data, unsigned size,
                            unsigned mb_count)
 {
-    void     *dxva_data;
+    void     *dxva_data = NULL;
     unsigned dxva_size;
     int      result;
     HRESULT hr = 0;
@@ -828,7 +828,7 @@  int ff_dxva2_commit_buffer(AVCodecContext *avctx,
                type, (unsigned)hr);
         return -1;
     }
-    if (size <= dxva_size) {
+    if (dxva_data && size <= dxva_size) {
         memcpy(dxva_data, data, size);
 
 #if CONFIG_D3D11VA