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


test/ssltest.c:843:1: start of procedure print_key_details()
841.   }
842.   
843. > static void print_key_details(BIO *out, EVP_PKEY *key)
844.   {
845.       int keyid = EVP_PKEY_id(key);

test/ssltest.c:845:5: 
843.   static void print_key_details(BIO *out, EVP_PKEY *key)
844.   {
845. >     int keyid = EVP_PKEY_id(key);
846.   #ifndef OPENSSL_NO_EC
847.       if (keyid == EVP_PKEY_EC) {

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

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

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

test/ssltest.c:847:9: Taking true branch
845.       int keyid = EVP_PKEY_id(key);
846.   #ifndef OPENSSL_NO_EC
847.       if (keyid == EVP_PKEY_EC) {
               ^
848.           EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);
849.           int nid;

test/ssltest.c:848:9: 
846.   #ifndef OPENSSL_NO_EC
847.       if (keyid == EVP_PKEY_EC) {
848. >         EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);
849.           int nid;
850.           const char *cname;

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

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

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

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

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

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

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

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

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

test/ssltest.c:851:9: 
849.           int nid;
850.           const char *cname;
851. >         nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));
852.           EC_KEY_free(ec);
853.           cname = EC_curve_nid2nist(nid);

crypto/ec/ec_key.c:438:1: start of procedure EC_KEY_get0_group()
  436.   }
  437.   
  438. > const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)
  439.   {
  440.       return key->group;

crypto/ec/ec_key.c:440:5: 
  438.   const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key)
  439.   {
  440. >     return key->group;
  441.   }
  442.   

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}']