Before 0f8763fbea4e8816cd54c2a481d4c048fec58394, av1_frame_ref() and update_reference_list() could fail and therefore needed to be checked, which incidentally set ret. This is no longer happening, leading to a potential use of an uninitialized value which is also the subject of Coverity ticket #1596605. Fix this by always setting ret before goto end; do not return some random ancient value.
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -1333,12 +1333,15 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) · 1332 unmodified lines | |||
| 1333 | 1333 | ||
| 1334 | if (s->cur_frame.f) { | 1334 | if (s->cur_frame.f) { |
| 1335 | ret = set_output_frame(avctx, frame); | 1335 | ret = set_output_frame(avctx, frame); |
| 1336 | if (ret < 0) | 1336 | if (ret < 0) { |
| 1337 | av_log(avctx, AV_LOG_ERROR, "Set output frame error.\n"); | 1337 | av_log(avctx, AV_LOG_ERROR, "Set output frame error.\n"); |
| 1338 | goto end; | ||
| 1339 | } | ||
| 1338 | } | 1340 | } |
| 1339 | 1341 | ||
| 1340 | s->raw_frame_header = NULL; | 1342 | s->raw_frame_header = NULL; |
| 1341 | i++; | 1343 | i++; |
| 1344 | ret = 0; | ||
| 1342 | 1345 | ||
| 1343 | goto end; | 1346 | goto end; |
| 1344 | } | 1347 | } |
| @@ -1439,17 +1442,20 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) · 94 unmodified lines | |||
| 1439 | 1442 | ||
| 1440 | update_reference_list(avctx); | 1443 | update_reference_list(avctx); |
| 1441 | 1444 | ||
| 1442 | if (s->raw_frame_header->show_frame && s->cur_frame.f) { | 1445 | raw_tile_group = NULL; |
| 1443 | ret = set_output_frame(avctx, frame); | ||
| 1444 | if (ret < 0) { | ||
| 1445 | av_log(avctx, AV_LOG_ERROR, "Set output frame error\n"); | ||
| 1446 | goto end; | ||
| 1447 | } | ||
| 1448 | } | ||
| 1449 | raw_tile_group = NULL; | ||
| 1450 | s->raw_frame_header = NULL; | 1446 | s->raw_frame_header = NULL; |
| 1447 | |||
| 1451 | if (show_frame) { | 1448 | if (show_frame) { |
| 1449 | // cur_frame.f needn't exist due to skip_frame. | ||
| 1450 | if (s->cur_frame.f) { | ||
| 1451 | ret = set_output_frame(avctx, frame); | ||
| 1452 | if (ret < 0) { | ||
| 1453 | av_log(avctx, AV_LOG_ERROR, "Set output frame error\n"); | ||
| 1454 | goto end; | ||
| 1455 | } | ||
| 1456 | } | ||
| 1452 | i++; | 1457 | i++; |
| 1458 | ret = 0; | ||
| 1453 | goto end; | 1459 | goto end; |
| 1454 | } | 1460 | } |
| 1455 | } | 1461 | } |