History

avcodec/av1dec: Always set ret before goto end

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.

Andreas Rheinhardt committed 2 years ago

Commit 9fb3d641 parent 86e418f1 file · +15 −9Browse files

Unified · Split

libavcodec/av1dec.c+15−9
@@ -1333,12 +1333,15 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) · 1332 unmodified lines
13331333
13341334 if (s->cur_frame.f) {
13351335 ret = set_output_frame(avctx, frame);
1336− if (ret < 0)
1336+ if (ret < 0) {
13371337 av_log(avctx, AV_LOG_ERROR, "Set output frame error.\n");
1338+ goto end;
1339+ }
13381340 }
13391341
13401342 s->raw_frame_header = NULL;
13411343 i++;
1344+ ret = 0;
13421345
13431346 goto end;
13441347 }
@@ -1439,17 +1442,20 @@ static int av1_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) · 94 unmodified lines
14391442
14401443 update_reference_list(avctx);
14411444
1442− if (s->raw_frame_header->show_frame && s->cur_frame.f) {
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;
1445+ raw_tile_group = NULL;
14501446 s->raw_frame_header = NULL;
1447+
14511448 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+ }
14521457 i++;
1458+ ret = 0;
14531459 goto end;
14541460 }
14551461 }

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