A badly behaving user provided mutex manager (such as that in OpenCV) may not reset the mutex to NULL on destruction. This can cause a problem for a later mutex manager (which may assert that the mutex is NULL before creating).
Signed-off-by: Manfred Georg <[email protected]> --- libavcodec/utils.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index a472076..47a1b1e 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2318,18 +2318,21 @@ AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel) int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) { if (lockmgr_cb) { - if (lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY)) - return -1; - if (lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY)) + void *old_codec_mutex = codec_mutex; + void *old_avformat_mutex = avformat_mutex; + int failure; + codec_mutex = NULL; + avformat_mutex = NULL; + failure = lockmgr_cb(&old_codec_mutex, AV_LOCK_DESTROY); + if (lockmgr_cb(&old_avformat_mutex, AV_LOCK_DESTROY) || failure) return -1; } lockmgr_cb = cb; if (lockmgr_cb) { - if (lockmgr_cb(&codec_mutex, AV_LOCK_CREATE)) - return -1; - if (lockmgr_cb(&avformat_mutex, AV_LOCK_CREATE)) + int failure = lockmgr_cb(&codec_mutex, AV_LOCK_CREATE); + if (lockmgr_cb(&avformat_mutex, AV_LOCK_CREATE) || failure) return -1; } return 0; -- 2.1.0.rc2.206.gedb03e5 _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
