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
354 const AV1DecContext *h = avctx->priv_data;354 const AV1DecContext *h = avctx->priv_data;
355 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);355 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
356 struct av1_dxva2_picture_context *ctx_pic = h->cur_frame.hwaccel_picture_private;356 struct av1_dxva2_picture_context *ctx_pic = h->cur_frame.hwaccel_picture_private;
357 void *dxva_data_ptr;357 void *dxva_data_ptr = NULL;
358 uint8_t *dxva_data;358 uint8_t *dxva_data;
359 unsigned dxva_size;359 unsigned dxva_size;
360 unsigned padding;360 unsigned padding;
@@ -382,7 +382,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 21 unmodified lines
382 382
383 dxva_data = dxva_data_ptr;383 dxva_data = dxva_data_ptr;
384 384
385 if (ctx_pic->bitstream_size > dxva_size) {385 if (!dxva_data || ctx_pic->bitstream_size > dxva_size) {
386 av_log(avctx, AV_LOG_ERROR, "Bitstream size exceeds hardware buffer");386 av_log(avctx, AV_LOG_ERROR, "Bitstream size exceeds hardware buffer");
387 return -1;387 return -1;
388 }388 }
libavcodec/dxva2_hevc.c+4−1
@@ -248,7 +248,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 247 unmodified lines
248 const HEVCFrame *current_picture = h->cur_frame;248 const HEVCFrame *current_picture = h->cur_frame;
249 struct hevc_dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;249 struct hevc_dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
250 DXVA_Slice_HEVC_Short *slice = NULL;250 DXVA_Slice_HEVC_Short *slice = NULL;
251 void *dxva_data_ptr;251 void *dxva_data_ptr = NULL;
252 uint8_t *dxva_data, *current, *end;252 uint8_t *dxva_data, *current, *end;
253 unsigned dxva_size;253 unsigned dxva_size;
254 void *slice_data;254 void *slice_data;
@@ -278,6 +278,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 23 unmodified lines
278 }278 }
279#endif279#endif
280 280
281 if (!dxva_data_ptr)
282 return -1;
283
281 dxva_data = dxva_data_ptr;284 dxva_data = dxva_data_ptr;
282 current = dxva_data;285 current = dxva_data;
283 end = dxva_data + dxva_size;286 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
160 s->cur_pic.ptr->hwaccel_picture_private;160 s->cur_pic.ptr->hwaccel_picture_private;
161 const int is_field = s->picture_structure != PICT_FRAME;161 const int is_field = s->picture_structure != PICT_FRAME;
162 const unsigned mb_count = s->mb_width * (s->mb_height >> is_field);162 const unsigned mb_count = s->mb_width * (s->mb_height >> is_field);
163 void *dxva_data_ptr;163 void *dxva_data_ptr = NULL;
164 uint8_t *dxva_data, *current, *end;164 uint8_t *dxva_data, *current, *end;
165 unsigned dxva_size;165 unsigned dxva_size;
166 unsigned i;166 unsigned i;
@@ -186,6 +186,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 19 unmodified lines
186 }186 }
187#endif187#endif
188 188
189 if (!dxva_data_ptr)
190 return -1;
191
189 dxva_data = dxva_data_ptr;192 dxva_data = dxva_data_ptr;
190 current = dxva_data;193 current = dxva_data;
191 end = dxva_data + dxva_size;194 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
197 const unsigned start_code_size = avctx->codec_id == AV_CODEC_ID_VC1 ? sizeof(start_code) : 0;197 const unsigned start_code_size = avctx->codec_id == AV_CODEC_ID_VC1 ? sizeof(start_code) : 0;
198 const unsigned mb_count = s->mb_width * (s->mb_height >> v->field_mode);198 const unsigned mb_count = s->mb_width * (s->mb_height >> v->field_mode);
199 DXVA_SliceInfo *slice = NULL;199 DXVA_SliceInfo *slice = NULL;
200 void *dxva_data_ptr;200 void *dxva_data_ptr = NULL;
201 uint8_t *dxva_data, *current, *end;201 uint8_t *dxva_data, *current, *end;
202 unsigned dxva_size;202 unsigned dxva_size;
203 unsigned padding;203 unsigned padding;
@@ -224,6 +224,9 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 20 unmodified lines
224 }224 }
225#endif225#endif
226 226
227 if (!dxva_data_ptr)
228 return -1;
229
227 dxva_data = dxva_data_ptr;230 dxva_data = dxva_data_ptr;
228 current = dxva_data;231 current = dxva_data;
229 end = dxva_data + dxva_size;232 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
172 const VP9SharedContext *h = avctx->priv_data;172 const VP9SharedContext *h = avctx->priv_data;
173 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);173 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
174 struct vp9_dxva2_picture_context *ctx_pic = h->frames[CUR_FRAME].hwaccel_picture_private;174 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;
176 uint8_t *dxva_data;176 uint8_t *dxva_data;
177 unsigned dxva_size;177 unsigned dxva_size;
178 unsigned padding;178 unsigned padding;
@@ -200,7 +200,7 @@ static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, · 21 unmodified lines
200 200
201 dxva_data = dxva_data_ptr;201 dxva_data = dxva_data_ptr;
202 202
203 if (ctx_pic->slice.SliceBytesInBuffer > dxva_size) {203 if (!dxva_data || ctx_pic->slice.SliceBytesInBuffer > dxva_size) {
204 av_log(avctx, AV_LOG_ERROR, "Failed to build bitstream");204 av_log(avctx, AV_LOG_ERROR, "Failed to build bitstream");
205 return -1;205 return -1;
206 }206 }

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