]> git.sesse.net Git - mlt/commitdiff
Make avformat_lockmgr() safer by setting mutex pointer NULL.
authorDan Dennedy <dan@dennedy.org>
Fri, 22 Mar 2013 02:42:45 +0000 (19:42 -0700)
committerDan Dennedy <dan@dennedy.org>
Fri, 22 Mar 2013 02:42:45 +0000 (19:42 -0700)
src/modules/avformat/factory.c

index a273537750be99045950a5c80c7b7cffd235e3b9..179eb3c7ec187b67675e30ad7eba68c5d0c2fd67 100644 (file)
@@ -66,17 +66,22 @@ static int avformat_lockmgr(void **mutex, enum AVLockOp op)
    {
    case AV_LOCK_CREATE:
       *pmutex = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t));
+       if (!*pmutex) return -1;
        pthread_mutex_init(*pmutex, NULL);
        break;
    case AV_LOCK_OBTAIN:
+       if (!*pmutex) return -1;
        pthread_mutex_lock(*pmutex);
        break;
    case AV_LOCK_RELEASE:
+       if (!*pmutex) return -1;
        pthread_mutex_unlock(*pmutex);
        break;
    case AV_LOCK_DESTROY:
+       if (!*pmutex) return -1;
        pthread_mutex_destroy(*pmutex);
        free(*pmutex);
+       *pmutex = NULL;
        break;
    }