Fix various incorrect error function codes.
[openssl.git] / crypto / ec / ec_asn1.c
index 6e3a02ab86a6fd1669756d9b363791944c0ffec5..d43ca49ec7ac1cda57b0455cd6954940fd852bb3 100644 (file)
@@ -384,7 +384,7 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field)
                                }
                        if (!ASN1_INTEGER_set(char_two->p.tpBasis, (long)k))
                                {
-                               ECerr(EC_F_EC_ASN1_GROUP2PARAMETERS,
+                               ECerr(EC_F_EC_ASN1_GROUP2FIELDID,
                                        ERR_R_ASN1_LIB);
                                goto err;
                                }
@@ -992,7 +992,7 @@ EC_GROUP *ec_asn1_pkparameters2group(const ECPKPARAMETERS *params)
                }
        else
                {
-               ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, EC_R_ASN1_ERROR);
+               ECerr(EC_F_EC_ASN1_PKPARAMETERS2GROUP, EC_R_ASN1_ERROR);
                return NULL;
                }
 
@@ -1226,16 +1226,17 @@ int     i2d_ECPrivateKey(EC_KEY *a, unsigned char **out)
                                a->conv_form, NULL, 0, NULL);
 
                if (tmp_len > buf_len)
-                       buffer = OPENSSL_realloc(buffer, tmp_len);
-               if (buffer == NULL)
                        {
-                       ECerr(EC_F_I2D_ECPRIVATEKEY,
-                               ERR_R_MALLOC_FAILURE);
-                       goto err;
+                       unsigned char *tmp_buffer = OPENSSL_realloc(buffer, tmp_len);
+                       if (!tmp_buffer)
+                               {
+                               ECerr(EC_F_I2D_ECPRIVATEKEY, ERR_R_MALLOC_FAILURE);
+                               goto err;
+                               }
+                       buffer = tmp_buffer;
+                       buf_len = tmp_len;
                        }
 
-               buf_len = tmp_len;
-
                if (!EC_POINT_point2oct(a->group, a->pub_key, 
                        a->conv_form, buffer, buf_len, NULL))
                        {