]> git.sur5r.net Git - openldap/commitdiff
Fix dangling lock (coverity)
authorHoward Chu <hyc@openldap.org>
Tue, 13 Jan 2015 20:52:46 +0000 (20:52 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 13 Jan 2015 21:13:46 +0000 (21:13 +0000)
libraries/librewrite/session.c
libraries/librewrite/xmap.c

index 02fc0540b33e2a18b011cbddf0d21a26a29c4b50..3554998972fa0a1bbb34b2ed5ad2312e461b3174 100644 (file)
@@ -100,6 +100,9 @@ rewrite_session_init(
                
        session = calloc( sizeof( struct rewrite_session ), 1 );
        if ( session == NULL ) {
+#ifdef USE_REWRITE_LDAP_PVT_THREADS
+               ldap_pvt_thread_rdwr_wunlock( &info->li_cookies_mutex );
+#endif /* USE_REWRITE_LDAP_PVT_THREADS */
                return NULL;
        }
        session->ls_cookie = ( void * )cookie;
@@ -108,11 +111,13 @@ rewrite_session_init(
 #ifdef USE_REWRITE_LDAP_PVT_THREADS
        if ( ldap_pvt_thread_mutex_init( &session->ls_mutex ) ) {
                free( session );
+               ldap_pvt_thread_rdwr_wunlock( &info->li_cookies_mutex );
                return NULL;
        }
        if ( ldap_pvt_thread_rdwr_init( &session->ls_vars_mutex ) ) {
                ldap_pvt_thread_mutex_destroy( &session->ls_mutex );
                free( session );
+               ldap_pvt_thread_rdwr_wunlock( &info->li_cookies_mutex );
                return NULL;
        }
 #endif /* USE_REWRITE_LDAP_PVT_THREADS */
@@ -122,7 +127,7 @@ rewrite_session_init(
        info->li_num_cookies++;
 
 #ifdef USE_REWRITE_LDAP_PVT_THREADS
-        ldap_pvt_thread_rdwr_wunlock( &info->li_cookies_mutex );
+       ldap_pvt_thread_rdwr_wunlock( &info->li_cookies_mutex );
 #endif /* USE_REWRITE_LDAP_PVT_THREADS */
        
        if ( rc != 0 ) {
index 4e92d87b513c0fd172baea1e3a6a4013d60faa67..430d6b236df9d4d3fc8304faee7aa34626779d80 100644 (file)
@@ -335,7 +335,11 @@ rewrite_xmap_apply(
                                        && ( p = strtok( NULL, "" ) ) ) {
                                val->bv_val = strdup( p );
                                if ( val->bv_val == NULL ) {
-                                       return REWRITE_ERR;
+#ifdef USE_REWRITE_LDAP_PVT_THREADS
+                                       ldap_pvt_thread_mutex_unlock( &map->lm_mutex );
+#endif /* USE_REWRITE_LDAP_PVT_THREADS */
+                                       rc = REWRITE_ERR;
+                                       goto rc_return;
                                }
 
                                val->bv_len = strlen( p );