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