]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Avoid relocking while enumerator is alive
authorMartin Willi <martin@revosec.ch>
Tue, 6 Jul 2010 13:44:37 +0000 (15:44 +0200)
committerMartin Willi <martin@revosec.ch>
Tue, 6 Jul 2010 14:28:25 +0000 (16:28 +0200)
src/libstrongswan/credentials/keys/key_encoding.c

index 89b25226c30bd42c19f79184a49c0f4d21714e09..d76ad0b239896783e981880dbf06ecd3f4ada026 100644 (file)
@@ -168,20 +168,21 @@ static bool encode(private_key_encoding_t *this, key_encoding_type_t type,
                va_end(copy);
                if (success)
                {
-                       if (cache)
-                       {
-                               chunk = malloc_thing(chunk_t);
-                               *chunk = *encoding;
-                               this->lock->unlock(this->lock);
-                               this->lock->write_lock(this->lock);
-                               this->cache[type]->put(this->cache[type], cache, chunk);
-                       }
                        break;
                }
        }
        enumerator->destroy(enumerator);
-       va_end(args);
        this->lock->unlock(this->lock);
+       va_end(args);
+
+       if (success && cache)
+       {
+               chunk = malloc_thing(chunk_t);
+               *chunk = *encoding;
+               this->lock->write_lock(this->lock);
+               this->cache[type]->put(this->cache[type], cache, chunk);
+               this->lock->unlock(this->lock);
+       }
        return success;
 }