crypto/dsa/dsa_ameth.c:335: error: MEMORY_LEAK
  memory dynamically allocated by call to `ASN1_STRING_new()` at line 300, column 14 is not reachable after line 335, column 5.
Showing all 57 steps of the trace


crypto/dsa/dsa_ameth.c:288:1: start of procedure dsa_priv_encode()
286.   }
287.   
288. > static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
289.   {
290.       ASN1_STRING *params = NULL;

crypto/dsa/dsa_ameth.c:290:5: 
288.   static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
289.   {
290. >     ASN1_STRING *params = NULL;
291.       ASN1_INTEGER *prkey = NULL;
292.       unsigned char *dp = NULL;

crypto/dsa/dsa_ameth.c:291:5: 
289.   {
290.       ASN1_STRING *params = NULL;
291. >     ASN1_INTEGER *prkey = NULL;
292.       unsigned char *dp = NULL;
293.       int dplen;

crypto/dsa/dsa_ameth.c:292:5: 
290.       ASN1_STRING *params = NULL;
291.       ASN1_INTEGER *prkey = NULL;
292. >     unsigned char *dp = NULL;
293.       int dplen;
294.   

crypto/dsa/dsa_ameth.c:295:10: Taking false branch
293.       int dplen;
294.   
295.       if (!pkey->pkey.dsa || !pkey->pkey.dsa->priv_key) {
                ^
296.           DSAerr(DSA_F_DSA_PRIV_ENCODE, DSA_R_MISSING_PARAMETERS);
297.           goto err;

crypto/dsa/dsa_ameth.c:295:29: Taking false branch
293.       int dplen;
294.   
295.       if (!pkey->pkey.dsa || !pkey->pkey.dsa->priv_key) {
                                   ^
296.           DSAerr(DSA_F_DSA_PRIV_ENCODE, DSA_R_MISSING_PARAMETERS);
297.           goto err;

crypto/dsa/dsa_ameth.c:300:5: 
298.       }
299.   
300. >     params = ASN1_STRING_new();
301.   
302.       if (params == NULL) {

crypto/asn1/asn1_lib.c:343:1: start of procedure ASN1_STRING_new()
  341.   }
  342.   
  343. > ASN1_STRING *ASN1_STRING_new(void)
  344.   {
  345.       return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING));

crypto/asn1/asn1_lib.c:345:5: 
  343.   ASN1_STRING *ASN1_STRING_new(void)
  344.   {
  345. >     return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING));
  346.   }
  347.   

crypto/asn1/asn1_lib.c:348:1: start of procedure ASN1_STRING_type_new()
    346.   }
    347.   
    348. > ASN1_STRING *ASN1_STRING_type_new(int type)
    349.   {
    350.       ASN1_STRING *ret;

crypto/asn1/asn1_lib.c:352:5: 
    350.       ASN1_STRING *ret;
    351.   
    352. >     ret = OPENSSL_zalloc(sizeof(*ret));
    353.       if (ret == NULL) {
    354.           ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);

crypto/mem.c:156:1: start of procedure CRYPTO_zalloc()
      154.   }
      155.   
      156. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
      157.   {
      158.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:158:5: 
      156.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
      157.   {
      158. >     void *ret = CRYPTO_malloc(num, file, line);
      159.   
      160.       if (ret != NULL)

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
        117.   }
        118.   
        119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
        120.   {
        121.       void *ret = NULL;

crypto/mem.c:121:5: 
        119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
        120.   {
        121. >     void *ret = NULL;
        122.   
        123.       if (num <= 0)

crypto/mem.c:123:9: Taking false branch
        121.       void *ret = NULL;
        122.   
        123.       if (num <= 0)
                       ^
        124.           return NULL;
        125.   

crypto/mem.c:126:5: 
        124.           return NULL;
        125.   
        126. >     allow_customize = 0;
        127.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
        128.       if (call_malloc_debug) {

crypto/mem.c:136:5: 
        134.       }
        135.   #else
        136. >     (void)file;
        137.       (void)line;
        138.       ret = malloc(num);

crypto/mem.c:137:5: 
        135.   #else
        136.       (void)file;
        137. >     (void)line;
        138.       ret = malloc(num);
        139.   #endif

crypto/mem.c:138:5: 
        136.       (void)file;
        137.       (void)line;
        138. >     ret = malloc(num);
        139.   #endif
        140.   

crypto/mem.c:153:5: 
        151.   #endif
        152.   
        153. >     return ret;
        154.   }
        155.   

crypto/mem.c:154:1: return from a call to CRYPTO_malloc
        152.   
        153.       return ret;
        154. > }
        155.   
        156.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:160:9: Taking true branch
      158.       void *ret = CRYPTO_malloc(num, file, line);
      159.   
      160.       if (ret != NULL)
                     ^
      161.           memset(ret, 0, num);
      162.       return ret;

crypto/mem.c:161:9: 
      159.   
      160.       if (ret != NULL)
      161. >         memset(ret, 0, num);
      162.       return ret;
      163.   }

crypto/mem.c:162:5: 
      160.       if (ret != NULL)
      161.           memset(ret, 0, num);
      162. >     return ret;
      163.   }
      164.   

crypto/mem.c:163:1: return from a call to CRYPTO_zalloc
      161.           memset(ret, 0, num);
      162.       return ret;
      163. > }
      164.   
      165.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/asn1/asn1_lib.c:353:9: Taking false branch
    351.   
    352.       ret = OPENSSL_zalloc(sizeof(*ret));
    353.       if (ret == NULL) {
                   ^
    354.           ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);
    355.           return (NULL);

crypto/asn1/asn1_lib.c:357:5: 
    355.           return (NULL);
    356.       }
    357. >     ret->type = type;
    358.       return (ret);
    359.   }

crypto/asn1/asn1_lib.c:358:5: 
    356.       }
    357.       ret->type = type;
    358. >     return (ret);
    359.   }
    360.   

crypto/asn1/asn1_lib.c:359:1: return from a call to ASN1_STRING_type_new
    357.       ret->type = type;
    358.       return (ret);
    359. > }
    360.   
    361.   void ASN1_STRING_free(ASN1_STRING *a)

crypto/asn1/asn1_lib.c:346:1: return from a call to ASN1_STRING_new
  344.   {
  345.       return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING));
  346. > }
  347.   
  348.   ASN1_STRING *ASN1_STRING_type_new(int type)

crypto/dsa/dsa_ameth.c:302:9: Taking false branch
300.       params = ASN1_STRING_new();
301.   
302.       if (params == NULL) {
               ^
303.           DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE);
304.           goto err;

crypto/dsa/dsa_ameth.c:307:5: 
305.       }
306.   
307. >     params->length = i2d_DSAparams(pkey->pkey.dsa, &params->data);
308.       if (params->length <= 0) {
309.           DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE);

crypto/dsa/dsa_asn1.c:126:1: start of procedure i2d_DSAparams()
  124.   } static_ASN1_SEQUENCE_END_cb(DSA, DSAparams)
  125.   
  126. > IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAparams, DSAparams)
  127.   
  128.   ASN1_SEQUENCE_cb(DSAPublicKey, dsa_cb) = {

crypto/asn1/tasn_enc.c:91:1: start of procedure ASN1_item_i2d()
    89.   }
    90.   
    91. > int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
    92.   {
    93.       return asn1_item_flags_i2d(val, out, it, 0);

crypto/asn1/tasn_enc.c:93:5: 
    91.   int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)
    92.   {
    93. >     return asn1_item_flags_i2d(val, out, it, 0);
    94.   }
    95.   

crypto/asn1/tasn_enc.c:103:1: start of procedure asn1_item_flags_i2d()
      101.    */
      102.   
      103. > static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,
      104.                                  const ASN1_ITEM *it, int flags)
      105.   {

crypto/asn1/tasn_enc.c:106:9: Taking true branch
      104.                                  const ASN1_ITEM *it, int flags)
      105.   {
      106.       if (out && !*out) {
                     ^
      107.           unsigned char *p, *buf;
      108.           int len;

crypto/asn1/tasn_enc.c:106:17: Taking false branch
      104.                                  const ASN1_ITEM *it, int flags)
      105.   {
      106.       if (out && !*out) {
                             ^
      107.           unsigned char *p, *buf;
      108.           int len;

crypto/asn1/tasn_enc.c:121:5: Skipping ASN1_item_ex_i2d(): empty list of specs
      119.       }
      120.   
      121.       return ASN1_item_ex_i2d(&val, out, it, -1, flags);
                 ^
      122.   }
      123.   

crypto/asn1/tasn_enc.c:122:1: return from a call to asn1_item_flags_i2d
      120.   
      121.       return ASN1_item_ex_i2d(&val, out, it, -1, flags);
      122. > }
      123.   
      124.   /*

crypto/asn1/tasn_enc.c:94:1: return from a call to ASN1_item_i2d
    92.   {
    93.       return asn1_item_flags_i2d(val, out, it, 0);
    94. > }
    95.   
    96.   /*

crypto/dsa/dsa_asn1.c:126:1: return from a call to i2d_DSAparams
  124.   } static_ASN1_SEQUENCE_END_cb(DSA, DSAparams)
  125.   
  126. > IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAparams, DSAparams)
  127.   
  128.   ASN1_SEQUENCE_cb(DSAPublicKey, dsa_cb) = {

crypto/dsa/dsa_ameth.c:308:9: Taking true branch
306.   
307.       params->length = i2d_DSAparams(pkey->pkey.dsa, &params->data);
308.       if (params->length <= 0) {
               ^
309.           DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE);
310.           goto err;

crypto/dsa/dsa_ameth.c:309:9: Skipping ERR_put_error(): empty list of specs
307.       params->length = i2d_DSAparams(pkey->pkey.dsa, &params->data);
308.       if (params->length <= 0) {
309.           DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE);
               ^
310.           goto err;
311.       }

crypto/dsa/dsa_ameth.c:333:2: 
331.       return 1;
332.   
333. >  err:
334.       OPENSSL_free(dp);
335.       ASN1_STRING_free(params);

crypto/dsa/dsa_ameth.c:334:5: 
332.   
333.    err:
334. >     OPENSSL_free(dp);
335.       ASN1_STRING_free(params);
336.       ASN1_STRING_clear_free(prkey);

crypto/mem.c:233:1: start of procedure CRYPTO_free()
  231.   }
  232.   
  233. > void CRYPTO_free(void *str)
  234.   {
  235.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:244:5: 
  242.       }
  243.   #else
  244. >     free(str);
  245.   #endif
  246.   }

crypto/mem.c:246:1: return from a call to CRYPTO_free
  244.       free(str);
  245.   #endif
  246. > }
  247.   
  248.   void CRYPTO_clear_free(void *str, size_t num)

crypto/dsa/dsa_ameth.c:335:5: 
333.    err:
334.       OPENSSL_free(dp);
335. >     ASN1_STRING_free(params);
336.       ASN1_STRING_clear_free(prkey);
337.       return 0;

crypto/asn1/asn1_lib.c:361:1: start of procedure ASN1_STRING_free()
  359.   }
  360.   
  361. > void ASN1_STRING_free(ASN1_STRING *a)
  362.   {
  363.       if (a == NULL)

crypto/asn1/asn1_lib.c:363:9: Taking false branch
  361.   void ASN1_STRING_free(ASN1_STRING *a)
  362.   {
  363.       if (a == NULL)
                 ^
  364.           return;
  365.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))

crypto/asn1/asn1_lib.c:365:11: Taking false branch
  363.       if (a == NULL)
  364.           return;
  365.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))
                   ^
  366.           OPENSSL_free(a->data);
  367.       if (!(a->flags & ASN1_STRING_FLAG_EMBED))

crypto/asn1/asn1_lib.c:367:11: Taking false branch
  365.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))
  366.           OPENSSL_free(a->data);
  367.       if (!(a->flags & ASN1_STRING_FLAG_EMBED))
                   ^
  368.           OPENSSL_free(a);
  369.   }

crypto/asn1/asn1_lib.c:367:5: 
  365.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))
  366.           OPENSSL_free(a->data);
  367. >     if (!(a->flags & ASN1_STRING_FLAG_EMBED))
  368.           OPENSSL_free(a);
  369.   }

crypto/asn1/asn1_lib.c:369:1: return from a call to ASN1_STRING_free
  367.       if (!(a->flags & ASN1_STRING_FLAG_EMBED))
  368.           OPENSSL_free(a);
  369. > }
  370.   
  371.   void ASN1_STRING_clear_free(ASN1_STRING *a)

static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)
{
    ASN1_STRING *params = NULL;
    ASN1_INTEGER *prkey = NULL;
    unsigned char *dp = NULL;
    int dplen;
    if (!pkey->pkey.dsa || !pkey->pkey.dsa->priv_key) {
        DSAerr(DSA_F_DSA_PRIV_ENCODE, DSA_R_MISSING_PARAMETERS);
        goto err;
    }
    params = ASN1_STRING_new();
    if (params == NULL) {
        DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    params->length = i2d_DSAparams(pkey->pkey.dsa, &params->data);
    if (params->length <= 0) {
        DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    params->type = V_ASN1_SEQUENCE;
    prkey = BN_to_ASN1_INTEGER(pkey->pkey.dsa->priv_key, NULL);
    if (!prkey) {
        DSAerr(DSA_F_DSA_PRIV_ENCODE, DSA_R_BN_ERROR);
        goto err;
    }
    dplen = i2d_ASN1_INTEGER(prkey, &dp);
    ASN1_STRING_clear_free(prkey);
    prkey = NULL;
    if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_dsa), 0,
                         V_ASN1_SEQUENCE, params, dp, dplen))
        goto err;
    return 1;
 err:
    OPENSSL_free(dp);
    ASN1_STRING_free(params);
    ASN1_STRING_clear_free(prkey);
    return 0;
}
['static int dsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey)\n{\n    ASN1_STRING *params = NULL;\n    ASN1_INTEGER *prkey = NULL;\n    unsigned char *dp = NULL;\n    int dplen;\n    if (!pkey->pkey.dsa || !pkey->pkey.dsa->priv_key) {\n        DSAerr(DSA_F_DSA_PRIV_ENCODE, DSA_R_MISSING_PARAMETERS);\n        goto err;\n    }\n    params = ASN1_STRING_new();\n    if (params == NULL) {\n        DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    params->length = i2d_DSAparams(pkey->pkey.dsa, &params->data);\n    if (params->length <= 0) {\n        DSAerr(DSA_F_DSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    params->type = V_ASN1_SEQUENCE;\n    prkey = BN_to_ASN1_INTEGER(pkey->pkey.dsa->priv_key, NULL);\n    if (!prkey) {\n        DSAerr(DSA_F_DSA_PRIV_ENCODE, DSA_R_BN_ERROR);\n        goto err;\n    }\n    dplen = i2d_ASN1_INTEGER(prkey, &dp);\n    ASN1_STRING_clear_free(prkey);\n    prkey = NULL;\n    if (!PKCS8_pkey_set0(p8, OBJ_nid2obj(NID_dsa), 0,\n                         V_ASN1_SEQUENCE, params, dp, dplen))\n        goto err;\n    return 1;\n err:\n    OPENSSL_free(dp);\n    ASN1_STRING_free(params);\n    ASN1_STRING_clear_free(prkey);\n    return 0;\n}', 'ASN1_STRING *ASN1_STRING_new(void)\n{\n    return (ASN1_STRING_type_new(V_ASN1_OCTET_STRING));\n}', 'ASN1_STRING *ASN1_STRING_type_new(int type)\n{\n    ASN1_STRING *ret;\n    ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL) {\n        ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    ret->type = type;\n    return (ret);\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (num <= 0)\n        return NULL;\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)file;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}', 'IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DSA, DSAparams, DSAparams)', 'int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it)\n{\n    return asn1_item_flags_i2d(val, out, it, 0);\n}', 'static int asn1_item_flags_i2d(ASN1_VALUE *val, unsigned char **out,\n                               const ASN1_ITEM *it, int flags)\n{\n    if (out && !*out) {\n        unsigned char *p, *buf;\n        int len;\n        len = ASN1_item_ex_i2d(&val, NULL, it, -1, flags);\n        if (len <= 0)\n            return len;\n        buf = OPENSSL_malloc(len);\n        if (buf == NULL)\n            return -1;\n        p = buf;\n        ASN1_item_ex_i2d(&val, &p, it, -1, flags);\n        *out = buf;\n        return len;\n    }\n    return ASN1_item_ex_i2d(&val, out, it, -1, flags);\n}', 'void CRYPTO_free(void *str)\n{\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}', 'void ASN1_STRING_free(ASN1_STRING *a)\n{\n    if (a == NULL)\n        return;\n    if (!(a->flags & ASN1_STRING_FLAG_NDEF))\n        OPENSSL_free(a->data);\n    if (!(a->flags & ASN1_STRING_FLAG_EMBED))\n        OPENSSL_free(a);\n}']