test/ssltest_old.c:731: error: NULL_DEREFERENCE
  pointer `ec` last assigned on line 728 could be null and is dereferenced by call to `EC_KEY_get0_group()` at line 731, column 39.
Showing all 19 steps of the trace


test/ssltest_old.c:723:1: start of procedure print_key_details()
721.   }
722.   
723. > static void print_key_details(BIO *out, EVP_PKEY *key)
724.   {
725.       int keyid = EVP_PKEY_id(key);

test/ssltest_old.c:725:5: 
723.   static void print_key_details(BIO *out, EVP_PKEY *key)
724.   {
725. >     int keyid = EVP_PKEY_id(key);
726.   #ifndef OPENSSL_NO_EC
727.       if (keyid == EVP_PKEY_EC) {

crypto/evp/p_lib.c:407:1: start of procedure EVP_PKEY_id()
  405.   }
  406.   
  407. > int EVP_PKEY_id(const EVP_PKEY *pkey)
  408.   {
  409.       return pkey->type;

crypto/evp/p_lib.c:409:5: 
  407.   int EVP_PKEY_id(const EVP_PKEY *pkey)
  408.   {
  409. >     return pkey->type;
  410.   }
  411.   

crypto/evp/p_lib.c:410:1: return from a call to EVP_PKEY_id
  408.   {
  409.       return pkey->type;
  410. > }
  411.   
  412.   int EVP_PKEY_base_id(const EVP_PKEY *pkey)

test/ssltest_old.c:727:9: Taking true branch
725.       int keyid = EVP_PKEY_id(key);
726.   #ifndef OPENSSL_NO_EC
727.       if (keyid == EVP_PKEY_EC) {
               ^
728.           EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);
729.           int nid;

test/ssltest_old.c:728:9: 
726.   #ifndef OPENSSL_NO_EC
727.       if (keyid == EVP_PKEY_EC) {
728. >         EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);
729.           int nid;
730.           const char *cname;

crypto/evp/p_lib.c:354:1: start of procedure EVP_PKEY_get1_EC_KEY()
  352.   }
  353.   
  354. > EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
  355.   {
  356.       EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);

crypto/evp/p_lib.c:356:5: 
  354.   EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
  355.   {
  356. >     EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);
  357.       if (ret != NULL)
  358.           EC_KEY_up_ref(ret);

crypto/evp/p_lib.c:345:1: start of procedure EVP_PKEY_get0_EC_KEY()
    343.   }
    344.   
    345. > EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
    346.   {
    347.       if (pkey->type != EVP_PKEY_EC) {

crypto/evp/p_lib.c:347:9: Taking false branch
    345.   EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
    346.   {
    347.       if (pkey->type != EVP_PKEY_EC) {
                   ^
    348.           EVPerr(EVP_F_EVP_PKEY_GET0_EC_KEY, EVP_R_EXPECTING_A_EC_KEY);
    349.           return NULL;

crypto/evp/p_lib.c:351:5: 
    349.           return NULL;
    350.       }
    351. >     return pkey->pkey.ec;
    352.   }
    353.   

crypto/evp/p_lib.c:352:1: return from a call to EVP_PKEY_get0_EC_KEY
    350.       }
    351.       return pkey->pkey.ec;
    352. > }
    353.   
    354.   EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)

crypto/evp/p_lib.c:357:9: Taking false branch
  355.   {
  356.       EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);
  357.       if (ret != NULL)
                 ^
  358.           EC_KEY_up_ref(ret);
  359.       return ret;

crypto/evp/p_lib.c:359:5: 
  357.       if (ret != NULL)
  358.           EC_KEY_up_ref(ret);
  359. >     return ret;
  360.   }
  361.   #endif

crypto/evp/p_lib.c:360:1: return from a call to EVP_PKEY_get1_EC_KEY
  358.           EC_KEY_up_ref(ret);
  359.       return ret;
  360. > }
  361.   #endif
  362.   

test/ssltest_old.c:731:9: 
729.           int nid;
730.           const char *cname;
731. >         nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));
732.           EC_KEY_free(ec);
733.           cname = EC_curve_nid2nist(nid);

crypto/ec/ec_key.c:419:1: start of procedure EC_KEY_get0_group()
  417.   }
  418.   
  419. > const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)
  420.   {
  421.       return key->group;

crypto/ec/ec_key.c:421:5: 
  419.   const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)
  420.   {
  421. >     return key->group;
  422.   }
  423.   

static void print_key_details(BIO *out, EVP_PKEY *key)
{
    int keyid = EVP_PKEY_id(key);
#ifndef OPENSSL_NO_EC
    if (keyid == EVP_PKEY_EC) {
        EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);
        int nid;
        const char *cname;
        nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));
        EC_KEY_free(ec);
        cname = EC_curve_nid2nist(nid);
        if (!cname)
            cname = OBJ_nid2sn(nid);
        BIO_printf(out, "%d bits EC (%s)", EVP_PKEY_bits(key), cname);
    } else
#endif
    {
        const char *algname;
        switch (keyid) {
        case EVP_PKEY_RSA:
            algname = "RSA";
            break;
        case EVP_PKEY_DSA:
            algname = "DSA";
            break;
        case EVP_PKEY_DH:
            algname = "DH";
            break;
        default:
            algname = OBJ_nid2sn(keyid);
            break;
        }
        BIO_printf(out, "%d bits %s", EVP_PKEY_bits(key), algname);
    }
}
['static void print_key_details(BIO *out, EVP_PKEY *key)\n{\n    int keyid = EVP_PKEY_id(key);\n#ifndef OPENSSL_NO_EC\n    if (keyid == EVP_PKEY_EC) {\n        EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);\n        int nid;\n        const char *cname;\n        nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));\n        EC_KEY_free(ec);\n        cname = EC_curve_nid2nist(nid);\n        if (!cname)\n            cname = OBJ_nid2sn(nid);\n        BIO_printf(out, "%d bits EC (%s)", EVP_PKEY_bits(key), cname);\n    } else\n#endif\n    {\n        const char *algname;\n        switch (keyid) {\n        case EVP_PKEY_RSA:\n            algname = "RSA";\n            break;\n        case EVP_PKEY_DSA:\n            algname = "DSA";\n            break;\n        case EVP_PKEY_DH:\n            algname = "DH";\n            break;\n        default:\n            algname = OBJ_nid2sn(keyid);\n            break;\n        }\n        BIO_printf(out, "%d bits %s", EVP_PKEY_bits(key), algname);\n    }\n}', 'int EVP_PKEY_id(const EVP_PKEY *pkey)\n{\n    return pkey->type;\n}', 'EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)\n{\n    EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);\n    if (ret != NULL)\n        EC_KEY_up_ref(ret);\n    return ret;\n}', 'EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)\n{\n    if (pkey->type != EVP_PKEY_EC) {\n        EVPerr(EVP_F_EVP_PKEY_GET0_EC_KEY, EVP_R_EXPECTING_A_EC_KEY);\n        return NULL;\n    }\n    return pkey->pkey.ec;\n}', 'const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)\n{\n    return key->group;\n}']