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


test/ssltest_old.c:805:1: start of procedure print_key_details()
803.   }
804.   
805. > static void print_key_details(BIO *out, EVP_PKEY *key)
806.   {
807.       int keyid = EVP_PKEY_id(key);

test/ssltest_old.c:807:5: 
805.   static void print_key_details(BIO *out, EVP_PKEY *key)
806.   {
807. >     int keyid = EVP_PKEY_id(key);
808.   #ifndef OPENSSL_NO_EC
809.       if (keyid == EVP_PKEY_EC) {

crypto/evp/p_lib.c:378:1: start of procedure EVP_PKEY_id()
  376.   }
  377.   
  378. > int EVP_PKEY_id(const EVP_PKEY *pkey)
  379.   {
  380.       return pkey->type;

crypto/evp/p_lib.c:380:5: 
  378.   int EVP_PKEY_id(const EVP_PKEY *pkey)
  379.   {
  380. >     return pkey->type;
  381.   }
  382.   

crypto/evp/p_lib.c:381:1: return from a call to EVP_PKEY_id
  379.   {
  380.       return pkey->type;
  381. > }
  382.   
  383.   int EVP_PKEY_base_id(const EVP_PKEY *pkey)

test/ssltest_old.c:809:9: Taking true branch
807.       int keyid = EVP_PKEY_id(key);
808.   #ifndef OPENSSL_NO_EC
809.       if (keyid == EVP_PKEY_EC) {
               ^
810.           EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);
811.           int nid;

test/ssltest_old.c:810:9: 
808.   #ifndef OPENSSL_NO_EC
809.       if (keyid == EVP_PKEY_EC) {
810. >         EC_KEY *ec = EVP_PKEY_get1_EC_KEY(key);
811.           int nid;
812.           const char *cname;

crypto/evp/p_lib.c:325:1: start of procedure EVP_PKEY_get1_EC_KEY()
  323.   }
  324.   
  325. > EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
  326.   {
  327.       EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);

crypto/evp/p_lib.c:327:5: 
  325.   EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)
  326.   {
  327. >     EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);
  328.       if (ret != NULL)
  329.           EC_KEY_up_ref(ret);

crypto/evp/p_lib.c:316:1: start of procedure EVP_PKEY_get0_EC_KEY()
    314.   }
    315.   
    316. > EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
    317.   {
    318.       if (pkey->type != EVP_PKEY_EC) {

crypto/evp/p_lib.c:318:9: Taking false branch
    316.   EC_KEY *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)
    317.   {
    318.       if (pkey->type != EVP_PKEY_EC) {
                   ^
    319.           EVPerr(EVP_F_EVP_PKEY_GET0_EC_KEY, EVP_R_EXPECTING_A_EC_KEY);
    320.           return NULL;

crypto/evp/p_lib.c:322:5: 
    320.           return NULL;
    321.       }
    322. >     return pkey->pkey.ec;
    323.   }
    324.   

crypto/evp/p_lib.c:323:1: return from a call to EVP_PKEY_get0_EC_KEY
    321.       }
    322.       return pkey->pkey.ec;
    323. > }
    324.   
    325.   EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)

crypto/evp/p_lib.c:328:9: Taking false branch
  326.   {
  327.       EC_KEY *ret = EVP_PKEY_get0_EC_KEY(pkey);
  328.       if (ret != NULL)
                 ^
  329.           EC_KEY_up_ref(ret);
  330.       return ret;

crypto/evp/p_lib.c:330:5: 
  328.       if (ret != NULL)
  329.           EC_KEY_up_ref(ret);
  330. >     return ret;
  331.   }
  332.   #endif

crypto/evp/p_lib.c:331:1: return from a call to EVP_PKEY_get1_EC_KEY
  329.           EC_KEY_up_ref(ret);
  330.       return ret;
  331. > }
  332.   #endif
  333.   

test/ssltest_old.c:813:9: 
811.           int nid;
812.           const char *cname;
813. >         nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec));
814.           EC_KEY_free(ec);
815.           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}']