Fix unnecessary free in o2i_SM2CiphertextValue

The caller will crash when using the return value from
o2i_SM2CiphertextValue. Because the returned pointer to SM2CiphertextValue has been free,
regardless of success or failure in this method.

When assign cv to ret, cv should be set NULL just like the behaviour in
SM2_do_encrypt.
This commit is contained in:
Feng Jie
2018-08-02 11:07:34 +08:00
committed by Simon
parent 40b6623427
commit 38201e1161

View File

@@ -272,6 +272,7 @@ SM2CiphertextValue *o2i_SM2CiphertextValue(const EC_GROUP *group,
/* set result */
*pin = p;
ret = cv;
cv = NULL;
end:
if ((cv != *pout) && (!ret))