crypto/hmac/hm_ameth.c:117: error: MEMORY_LEAK
  memory dynamically allocated by call to `ASN1_OCTET_STRING_new()` at line 109, column 10 is not reachable after line 117, column 5.
Showing all 73 steps of the trace


crypto/hmac/hm_ameth.c:105:1: start of procedure old_hmac_decode()
103.    */
104.   
105. > static int old_hmac_decode(EVP_PKEY *pkey,
106.                              const unsigned char **pder, int derlen)
107.   {

crypto/hmac/hm_ameth.c:109:5: 
107.   {
108.       ASN1_OCTET_STRING *os;
109. >     os = ASN1_OCTET_STRING_new();
110.       if (os == NULL || !ASN1_OCTET_STRING_set(os, *pder, derlen))
111.           goto err;

crypto/asn1/tasn_typ.c:77:1: start of procedure ASN1_OCTET_STRING_new()
  75.   }
  76.   
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

crypto/asn1/tasn_typ.c:77:1: return from a call to ASN1_OCTET_STRING_new
  75.   }
  76.   
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)

crypto/hmac/hm_ameth.c:110:9: Taking false branch
108.       ASN1_OCTET_STRING *os;
109.       os = ASN1_OCTET_STRING_new();
110.       if (os == NULL || !ASN1_OCTET_STRING_set(os, *pder, derlen))
               ^
111.           goto err;
112.       if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os))

crypto/hmac/hm_ameth.c:110:24: 
108.       ASN1_OCTET_STRING *os;
109.       os = ASN1_OCTET_STRING_new();
110. >     if (os == NULL || !ASN1_OCTET_STRING_set(os, *pder, derlen))
111.           goto err;
112.       if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os))

crypto/asn1/a_octet.c:74:1: start of procedure ASN1_OCTET_STRING_set()
  72.   }
  73.   
  74. > int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, const unsigned char *d,
  75.                             int len)
  76.   {

crypto/asn1/a_octet.c:77:5: 
  75.                             int len)
  76.   {
  77. >     return ASN1_STRING_set(x, d, len);
  78.   }

crypto/asn1/asn1_lib.c:308:1: start of procedure ASN1_STRING_set()
    306.   }
    307.   
    308. > int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
    309.   {
    310.       unsigned char *c;

crypto/asn1/asn1_lib.c:311:5: 
    309.   {
    310.       unsigned char *c;
    311. >     const char *data = _data;
    312.   
    313.       if (len < 0) {

crypto/asn1/asn1_lib.c:313:9: Taking false branch
    311.       const char *data = _data;
    312.   
    313.       if (len < 0) {
                   ^
    314.           if (data == NULL)
    315.               return (0);

crypto/asn1/asn1_lib.c:319:10: Taking true branch
    317.               len = strlen(data);
    318.       }
    319.       if ((str->length < len) || (str->data == NULL)) {
                    ^
    320.           c = str->data;
    321.           str->data = OPENSSL_realloc(c, len + 1);

crypto/asn1/asn1_lib.c:320:9: 
    318.       }
    319.       if ((str->length < len) || (str->data == NULL)) {
    320. >         c = str->data;
    321.           str->data = OPENSSL_realloc(c, len + 1);
    322.           if (str->data == NULL) {

crypto/asn1/asn1_lib.c:321:9: 
    319.       if ((str->length < len) || (str->data == NULL)) {
    320.           c = str->data;
    321. >         str->data = OPENSSL_realloc(c, len + 1);
    322.           if (str->data == NULL) {
    323.               ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);

crypto/mem.c:166:1: start of procedure CRYPTO_realloc()
      164.   }
      165.   
      166. > void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
      167.   {
      168.       if (str == NULL)

crypto/mem.c:168:9: Taking false branch
      166.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
      167.   {
      168.       if (str == NULL)
                     ^
      169.           return CRYPTO_malloc(num, file, line);
      170.   

crypto/mem.c:171:9: Taking false branch
      169.           return CRYPTO_malloc(num, file, line);
      170.   
      171.       if (num == 0) {
                     ^
      172.           CRYPTO_free(str);
      173.           return NULL;

crypto/mem.c:176:5: 
      174.       }
      175.   
      176. >     allow_customize = 0;
      177.   #ifdef CRYPTO_MDEBUG
      178.       if (call_malloc_debug) {

crypto/mem.c:186:5: 
      184.       }
      185.   #else
      186. >     (void)file;
      187.       (void)line;
      188.   #endif

crypto/mem.c:187:5: 
      185.   #else
      186.       (void)file;
      187. >     (void)line;
      188.   #endif
      189.       return realloc(str, num);

crypto/mem.c:189:5: 
      187.       (void)line;
      188.   #endif
      189. >     return realloc(str, num);
      190.   
      191.   }

crypto/mem.c:191:1: return from a call to CRYPTO_realloc
      189.       return realloc(str, num);
      190.   
      191. > }
      192.   
      193.   void *CRYPTO_clear_realloc(void *str, size_t old_len, size_t num,

crypto/asn1/asn1_lib.c:322:13: Taking false branch
    320.           c = str->data;
    321.           str->data = OPENSSL_realloc(c, len + 1);
    322.           if (str->data == NULL) {
                       ^
    323.               ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);
    324.               str->data = c;

crypto/asn1/asn1_lib.c:328:5: 
    326.           }
    327.       }
    328. >     str->length = len;
    329.       if (data != NULL) {
    330.           memcpy(str->data, data, len);

crypto/asn1/asn1_lib.c:329:9: Taking true branch
    327.       }
    328.       str->length = len;
    329.       if (data != NULL) {
                   ^
    330.           memcpy(str->data, data, len);
    331.           /* an allowance for strings :-) */

crypto/asn1/asn1_lib.c:330:9: 
    328.       str->length = len;
    329.       if (data != NULL) {
    330. >         memcpy(str->data, data, len);
    331.           /* an allowance for strings :-) */
    332.           str->data[len] = '\0';

crypto/asn1/asn1_lib.c:332:9: 
    330.           memcpy(str->data, data, len);
    331.           /* an allowance for strings :-) */
    332. >         str->data[len] = '\0';
    333.       }
    334.       return (1);

crypto/asn1/asn1_lib.c:334:5: 
    332.           str->data[len] = '\0';
    333.       }
    334. >     return (1);
    335.   }
    336.   

crypto/asn1/asn1_lib.c:335:1: return from a call to ASN1_STRING_set
    333.       }
    334.       return (1);
    335. > }
    336.   
    337.   void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len)

crypto/asn1/a_octet.c:78:1: return from a call to ASN1_OCTET_STRING_set
  76.   {
  77.       return ASN1_STRING_set(x, d, len);
  78. > }

crypto/hmac/hm_ameth.c:110:24: Taking false branch
108.       ASN1_OCTET_STRING *os;
109.       os = ASN1_OCTET_STRING_new();
110.       if (os == NULL || !ASN1_OCTET_STRING_set(os, *pder, derlen))
                              ^
111.           goto err;
112.       if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os))

crypto/hmac/hm_ameth.c:112:10: 
110.       if (os == NULL || !ASN1_OCTET_STRING_set(os, *pder, derlen))
111.           goto err;
112. >     if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os))
113.           goto err;
114.       return 1;

crypto/evp/p_lib.c:270:1: start of procedure EVP_PKEY_assign()
  268.   }
  269.   
  270. > int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key)
  271.   {
  272.       if (pkey == NULL || !EVP_PKEY_set_type(pkey, type))

crypto/evp/p_lib.c:272:9: Taking false branch
  270.   int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key)
  271.   {
  272.       if (pkey == NULL || !EVP_PKEY_set_type(pkey, type))
                 ^
  273.           return 0;
  274.       pkey->pkey.ptr = key;

crypto/evp/p_lib.c:272:26: 
  270.   int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key)
  271.   {
  272. >     if (pkey == NULL || !EVP_PKEY_set_type(pkey, type))
  273.           return 0;
  274.       pkey->pkey.ptr = key;

crypto/evp/p_lib.c:260:1: start of procedure EVP_PKEY_set_type()
    258.   }
    259.   
    260. > int EVP_PKEY_set_type(EVP_PKEY *pkey, int type)
    261.   {
    262.       return pkey_set_type(pkey, type, NULL, -1);

crypto/evp/p_lib.c:262:5: Skipping pkey_set_type(): empty list of specs
    260.   int EVP_PKEY_set_type(EVP_PKEY *pkey, int type)
    261.   {
    262.       return pkey_set_type(pkey, type, NULL, -1);
               ^
    263.   }
    264.   

crypto/evp/p_lib.c:263:1: return from a call to EVP_PKEY_set_type
    261.   {
    262.       return pkey_set_type(pkey, type, NULL, -1);
    263. > }
    264.   
    265.   int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len)

crypto/evp/p_lib.c:272:26: Taking true branch
  270.   int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key)
  271.   {
  272.       if (pkey == NULL || !EVP_PKEY_set_type(pkey, type))
                                  ^
  273.           return 0;
  274.       pkey->pkey.ptr = key;

crypto/evp/p_lib.c:273:9: 
  271.   {
  272.       if (pkey == NULL || !EVP_PKEY_set_type(pkey, type))
  273. >         return 0;
  274.       pkey->pkey.ptr = key;
  275.       return (key != NULL);

crypto/evp/p_lib.c:276:1: return from a call to EVP_PKEY_assign
  274.       pkey->pkey.ptr = key;
  275.       return (key != NULL);
  276. > }
  277.   
  278.   void *EVP_PKEY_get0(EVP_PKEY *pkey)

crypto/hmac/hm_ameth.c:112:10: Taking true branch
110.       if (os == NULL || !ASN1_OCTET_STRING_set(os, *pder, derlen))
111.           goto err;
112.       if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os))
                ^
113.           goto err;
114.       return 1;

crypto/hmac/hm_ameth.c:116:2: 
114.       return 1;
115.   
116. >  err:
117.       ASN1_OCTET_STRING_free(os);
118.       return 0;

crypto/hmac/hm_ameth.c:117:5: 
115.   
116.    err:
117. >     ASN1_OCTET_STRING_free(os);
118.       return 0;
119.   }

crypto/asn1/tasn_typ.c:77:1: start of procedure ASN1_OCTET_STRING_free()
  75.   }
  76.   
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)

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

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

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

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

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

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

crypto/asn1/tasn_typ.c:77:1: return from a call to ASN1_OCTET_STRING_free
  75.   }
  76.   
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)

static int old_hmac_decode(EVP_PKEY *pkey,
                           const unsigned char **pder, int derlen)
{
    ASN1_OCTET_STRING *os;
    os = ASN1_OCTET_STRING_new();
    if (os == NULL || !ASN1_OCTET_STRING_set(os, *pder, derlen))
        goto err;
    if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os))
        goto err;
    return 1;
 err:
    ASN1_OCTET_STRING_free(os);
    return 0;
}
['static int old_hmac_decode(EVP_PKEY *pkey,\n                           const unsigned char **pder, int derlen)\n{\n    ASN1_OCTET_STRING *os;\n    os = ASN1_OCTET_STRING_new();\n    if (os == NULL || !ASN1_OCTET_STRING_set(os, *pder, derlen))\n        goto err;\n    if (!EVP_PKEY_assign(pkey, EVP_PKEY_HMAC, os))\n        goto err;\n    return 1;\n err:\n    ASN1_OCTET_STRING_free(os);\n    return 0;\n}', 'IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)', '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#ifdef 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}', 'int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *x, const unsigned char *d,\n                          int len)\n{\n    return ASN1_STRING_set(x, d, len);\n}', "int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)\n{\n    unsigned char *c;\n    const char *data = _data;\n    if (len < 0) {\n        if (data == NULL)\n            return (0);\n        else\n            len = strlen(data);\n    }\n    if ((str->length < len) || (str->data == NULL)) {\n        c = str->data;\n        str->data = OPENSSL_realloc(c, len + 1);\n        if (str->data == NULL) {\n            ASN1err(ASN1_F_ASN1_STRING_SET, ERR_R_MALLOC_FAILURE);\n            str->data = c;\n            return (0);\n        }\n    }\n    str->length = len;\n    if (data != NULL) {\n        memcpy(str->data, data, len);\n        str->data[len] = '\\0';\n    }\n    return (1);\n}", 'void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)\n{\n    if (str == NULL)\n        return CRYPTO_malloc(num, file, line);\n    if (num == 0) {\n        CRYPTO_free(str);\n        return NULL;\n    }\n    allow_customize = 0;\n#ifdef CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        void *ret;\n        CRYPTO_mem_debug_realloc(str, NULL, num, 0, file, line);\n        ret = realloc(str, num);\n        CRYPTO_mem_debug_realloc(str, ret, num, 1, file, line);\n        return ret;\n    }\n#else\n    (void)file;\n    (void)line;\n#endif\n    return realloc(str, num);\n}', 'int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key)\n{\n    if (pkey == NULL || !EVP_PKEY_set_type(pkey, type))\n        return 0;\n    pkey->pkey.ptr = key;\n    return (key != NULL);\n}', 'int EVP_PKEY_set_type(EVP_PKEY *pkey, int type)\n{\n    return pkey_set_type(pkey, type, NULL, -1);\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}']