Revert 8f44a1dfacfde9ec4ab1dc5fc3bbc0b0b5bd2fba.
The man page of longjmp says:
https://en.cppreference.com/w/c/program/longjmp
If the function that called setjmp has exited (whether by return or by
a different longjmp higher up the stack), the behavior is undefined.
In other words, only long jumps up the call stack are allowed.
Therefore, we cannot call setjmp() in a call_setjmp() function that
immediately returns.
Note: The example code in the same man page also says:
local vars must be volatile for setjmp
I will deal with that separately.
BUG=oss-fuzz:9463
Change-Id: I7419122f68f67ab4e27be6636d3f8a2d926ee460
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index f200376..0bd484f 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -3047,16 +3047,6 @@
#endif
}
-static int call_setjmp(DecWorkerData *const thread_data) {
- if (setjmp(thread_data->error_info.jmp)) {
- thread_data->error_info.setjmp = 0;
- thread_data->td->xd.corrupted = 1;
- return 0;
- }
- thread_data->error_info.setjmp = 1;
- return 1;
-}
-
static int tile_worker_hook(void *arg1, void *arg2) {
DecWorkerData *const thread_data = (DecWorkerData *)arg1;
AV1Decoder *const pbi = (AV1Decoder *)arg2;
@@ -3064,9 +3054,12 @@
ThreadData *const td = thread_data->td;
uint8_t allow_update_cdf;
- if (!call_setjmp(thread_data)) {
+ if (setjmp(thread_data->error_info.jmp)) {
+ thread_data->error_info.setjmp = 0;
+ thread_data->td->xd.corrupted = 1;
return 0;
}
+ thread_data->error_info.setjmp = 1;
allow_update_cdf = cm->large_scale_tile ? 0 : 1;
allow_update_cdf = allow_update_cdf && !cm->disable_cdf_update;
@@ -3212,7 +3205,9 @@
AV1DecRowMTInfo *frame_row_mt_info = &pbi->frame_row_mt_info;
td->xd.corrupted = 0;
- if (!call_setjmp(thread_data)) {
+ if (setjmp(thread_data->error_info.jmp)) {
+ thread_data->error_info.setjmp = 0;
+ thread_data->td->xd.corrupted = 1;
#if CONFIG_MULTITHREAD
pthread_mutex_lock(pbi->row_mt_mutex_);
#endif
@@ -3222,6 +3217,7 @@
#endif
return 0;
}
+ thread_data->error_info.setjmp = 1;
const int num_planes = av1_num_planes(cm);
allow_update_cdf = cm->large_scale_tile ? 0 : 1;