History

avcodec/dxva2_*: Initialize dxva_data_ptr

Related: CID1591888 Uninitialized scalar variable Related: CID1591925 Uninitialized pointer read Related: CID1591933 Uninitialized scalar variable

Michael Niedermayer committed 2 years ago

Commit 189bc841 parent 1d6a2ae5 files · +16 −7Browse files

Unified · Split

5 files
  1. libavcodec/dxva2_av1.c +2 −2
  2. libavcodec/dxva2_hevc.c +4 −1
  3. libavcodec/dxva2_mpeg2.c +4 −1
  4. libavcodec/dxva2_vc1.c +4 −1
  5. libavcodec/dxva2_vp9.c +2 −2
libavcodec/dxva2_av1.c+2−2
@@ -354,7 +354,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 353 unmodified lines
354354 const AV1DecContext *h = avctx->priv_data;
355355 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
356356 struct av1_dxva2_picture_context *ctx_pic = h->cur_frame.hwaccel_picture_private;
357− void *dxva_data_ptr;
357+ void *dxva_data_ptr = NULL;
358358 uint8_t *dxva_data;
359359 unsigned dxva_size;
360360 unsigned padding;
@@ -382,7 +382,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 21 unmodified lines
382382
383383 dxva_data = dxva_data_ptr;
384384
385− if (ctx_pic->bitstream_size > dxva_size) {
385+ if (!dxva_data || ctx_pic->bitstream_size > dxva_size) {
386386 av_log(avctx, AV_LOG_ERROR, "Bitstream size exceeds hardware buffer");
387387 return -1;
388388 }
libavcodec/dxva2_hevc.c+4−1
@@ -248,7 +248,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 247 unmodified lines
248248 const HEVCFrame *current_picture = h->cur_frame;
249249 struct hevc_dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
250250 DXVA_Slice_HEVC_Short *slice = NULL;
251− void *dxva_data_ptr;
251+ void *dxva_data_ptr = NULL;
252252 uint8_t *dxva_data, *current, *end;
253253 unsigned dxva_size;
254254 void *slice_data;
@@ -278,6 +278,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 23 unmodified lines
278278 }
279279 #endif
280280
281+ if (!dxva_data_ptr)
282+ return -1;
283+
281284 dxva_data = dxva_data_ptr;
282285 current = dxva_data;
283286 end = dxva_data + dxva_size;
libavcodec/dxva2_mpeg2.c+4−1
@@ -160,7 +160,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 159 unmodified lines
160160 s->cur_pic.ptr->hwaccel_picture_private;
161161 const int is_field = s->picture_structure != PICT_FRAME;
162162 const unsigned mb_count = s->mb_width * (s->mb_height >> is_field);
163− void *dxva_data_ptr;
163+ void *dxva_data_ptr = NULL;
164164 uint8_t *dxva_data, *current, *end;
165165 unsigned dxva_size;
166166 unsigned i;
@@ -186,6 +186,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 19 unmodified lines
186186 }
187187 #endif
188188
189+ if (!dxva_data_ptr)
190+ return -1;
191+
189192 dxva_data = dxva_data_ptr;
190193 current = dxva_data;
191194 end = dxva_data + dxva_size;
libavcodec/dxva2_vc1.c+4−1
@@ -197,7 +197,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 196 unmodified lines
197197 const unsigned start_code_size = avctx->codec_id == AV_CODEC_ID_VC1 ? sizeof(start_code) : 0;
198198 const unsigned mb_count = s->mb_width * (s->mb_height >> v->field_mode);
199199 DXVA_SliceInfo *slice = NULL;
200− void *dxva_data_ptr;
200+ void *dxva_data_ptr = NULL;
201201 uint8_t *dxva_data, *current, *end;
202202 unsigned dxva_size;
203203 unsigned padding;
@@ -224,6 +224,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 20 unmodified lines
224224 }
225225 #endif
226226
227+ if (!dxva_data_ptr)
228+ return -1;
229+
227230 dxva_data = dxva_data_ptr;
228231 current = dxva_data;
229232 end = dxva_data + dxva_size;
libavcodec/dxva2_vp9.c+2−2
@@ -172,7 +172,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 171 unmodified lines
172172 const VP9SharedContext *h = avctx->priv_data;
173173 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
174174 struct vp9_dxva2_picture_context *ctx_pic = h->frames[CUR_FRAME].hwaccel_picture_private;
175− void *dxva_data_ptr;
175+ void *dxva_data_ptr = NULL;
176176 uint8_t *dxva_data;
177177 unsigned dxva_size;
178178 unsigned padding;
@@ -200,7 +200,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 21 unmodified lines
200200
201201 dxva_data = dxva_data_ptr;
202202
203− if (ctx_pic->slice.SliceBytesInBuffer > dxva_size) {
203+ if (!dxva_data || ctx_pic->slice.SliceBytesInBuffer > dxva_size) {
204204 av_log(avctx, AV_LOG_ERROR, "Failed to build bitstream");
205205 return -1;
206206 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t