X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fcryptlib.c;h=830ccc9816fed171af843429023e35e9fd9481cf;hb=442d42300b754f1aea6f2d903e548bb42bda7649;hp=38e2a533942846aab83145d8331ddaa3219e5097;hpb=75e1c74724698e1094e13f03ec9e708db25f686d;p=oweals%2Fopenssl.git diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c index 38e2a53394..830ccc9816 100644 --- a/crypto/cryptlib.c +++ b/crypto/cryptlib.c @@ -269,10 +269,18 @@ int CRYPTO_get_new_dynlockid(void) i=sk_CRYPTO_dynlock_find(dyn_locks,NULL); /* If there was none, push, thereby creating a new one */ if (i == -1) - i=sk_CRYPTO_dynlock_push(dyn_locks,pointer); + /* Since sk_push() returns the number of items on the + stack, not the location of the pushed item, we need + to transform the returned number into a position, + by decreasing it. */ + i=sk_CRYPTO_dynlock_push(dyn_locks,pointer) - 1; + else + /* If we found a place with a NULL pointer, put our pointer + in it. */ + sk_CRYPTO_dynlock_set(dyn_locks,i,pointer); CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK); - if (!i) + if (i == -1) { dynlock_destroy_callback(pointer->data,__FILE__,__LINE__); OPENSSL_free(pointer); @@ -467,7 +475,9 @@ void CRYPTO_lock(int mode, int type, const char *file, int line) struct CRYPTO_dynlock_value *pointer = CRYPTO_get_dynlock_value(type); - if (pointer && dynlock_lock_callback) + OPENSSL_assert(pointer != NULL); + + if (dynlock_lock_callback) { dynlock_lock_callback(mode, pointer, file, line); }