Structural references should never be decremented directly - so leave that
to ENGINE_free(). Also, remove "#if 0" code that has no useful future.
This commit is contained in:
parent
e3f1223fe4
commit
ea3a429efe
@ -231,10 +231,12 @@ ENGINE *ENGINE_get_next(ENGINE *e)
|
|||||||
}
|
}
|
||||||
CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
|
CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
|
||||||
ret = e->next;
|
ret = e->next;
|
||||||
e->struct_ref--;
|
|
||||||
if(ret)
|
if(ret)
|
||||||
|
/* Return a valid structural refernce to the next ENGINE */
|
||||||
ret->struct_ref++;
|
ret->struct_ref++;
|
||||||
CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
|
CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
|
||||||
|
/* Release the structural reference to the previous ENGINE */
|
||||||
|
ENGINE_free(e);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ENGINE *ENGINE_get_prev(ENGINE *e)
|
ENGINE *ENGINE_get_prev(ENGINE *e)
|
||||||
@ -248,10 +250,12 @@ ENGINE *ENGINE_get_prev(ENGINE *e)
|
|||||||
}
|
}
|
||||||
CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
|
CRYPTO_r_lock(CRYPTO_LOCK_ENGINE);
|
||||||
ret = e->prev;
|
ret = e->prev;
|
||||||
e->struct_ref--;
|
|
||||||
if(ret)
|
if(ret)
|
||||||
|
/* Return a valid structural reference to the next ENGINE */
|
||||||
ret->struct_ref++;
|
ret->struct_ref++;
|
||||||
CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
|
CRYPTO_r_unlock(CRYPTO_LOCK_ENGINE);
|
||||||
|
/* Release the structural reference to the previous ENGINE */
|
||||||
|
ENGINE_free(e);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,37 +335,6 @@ ENGINE *ENGINE_by_id(const char *id)
|
|||||||
return iterator;
|
return iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* As per the comments in engine.h, it is generally better all round
|
|
||||||
* if the ENGINE structure is allocated within this framework. */
|
|
||||||
#if 0
|
|
||||||
int ENGINE_get_struct_size(void)
|
|
||||||
{
|
|
||||||
return sizeof(ENGINE);
|
|
||||||
}
|
|
||||||
|
|
||||||
ENGINE *ENGINE_new(ENGINE *e)
|
|
||||||
{
|
|
||||||
ENGINE *ret;
|
|
||||||
|
|
||||||
if(e == NULL)
|
|
||||||
{
|
|
||||||
ret = (ENGINE *)(OPENSSL_malloc(sizeof(ENGINE));
|
|
||||||
if(ret == NULL)
|
|
||||||
{
|
|
||||||
ENGINEerr(ENGINE_F_ENGINE_NEW,
|
|
||||||
ERR_R_MALLOC_FAILURE);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ret = e;
|
|
||||||
memset(ret, 0, sizeof(ENGINE));
|
|
||||||
if(e)
|
|
||||||
ret->flags = ENGINE_FLAGS_MALLOCED;
|
|
||||||
ret->struct_ref = 1;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
ENGINE *ENGINE_new(void)
|
ENGINE *ENGINE_new(void)
|
||||||
{
|
{
|
||||||
ENGINE *ret;
|
ENGINE *ret;
|
||||||
@ -377,7 +350,6 @@ ENGINE *ENGINE_new(void)
|
|||||||
ret->struct_ref = 1;
|
ret->struct_ref = 1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int ENGINE_free(ENGINE *e)
|
int ENGINE_free(ENGINE *e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user