Fix missing pthread_mutex_unlock calls on error
Fix mutex locking bugs introduced in
https://aomedia-review.googlesource.com/c/aom/+/181161.
If we have locked a mutex, we must unlock the mutex before returning a
failure status.
Bug: aomedia:3276
Change-Id: I3c156bc8cff8a7cdb960bcfb244efcad792b7bb1
diff --git a/aom_dsp/flow_estimation/corner_detect.c b/aom_dsp/flow_estimation/corner_detect.c
index a83ca2b..43b5255 100644
--- a/aom_dsp/flow_estimation/corner_detect.c
+++ b/aom_dsp/flow_estimation/corner_detect.c
@@ -110,14 +110,14 @@
#endif // CONFIG_MULTITHREAD
if (!corners->valid) {
- if (!compute_corner_list(pyr, corners)) return false;
- corners->valid = true;
+ corners->valid = compute_corner_list(pyr, corners);
}
+ bool valid = corners->valid;
#if CONFIG_MULTITHREAD
pthread_mutex_unlock(&corners->mutex);
#endif // CONFIG_MULTITHREAD
- return true;
+ return valid;
}
#ifndef NDEBUG
diff --git a/aom_dsp/pyramid.c b/aom_dsp/pyramid.c
index 22c583c..11f9f1a 100644
--- a/aom_dsp/pyramid.c
+++ b/aom_dsp/pyramid.c
@@ -346,9 +346,9 @@
#endif // CONFIG_MULTITHREAD
if (!pyr->valid) {
- if (!fill_pyramid(frame, bit_depth, pyr)) return false;
- pyr->valid = true;
+ pyr->valid = fill_pyramid(frame, bit_depth, pyr);
}
+ bool valid = pyr->valid;
// At this point, the pyramid is guaranteed to be valid, and can be safely
// read from without holding the mutex any more
@@ -356,7 +356,7 @@
#if CONFIG_MULTITHREAD
pthread_mutex_unlock(&pyr->mutex);
#endif // CONFIG_MULTITHREAD
- return true;
+ return valid;
}
#ifndef NDEBUG