engines/ccgost/gost_pmeth.c:38: error: MEMORY_LEAK
  memory dynamically allocated to `return` by call to `CRYPTO_zalloc()` at line 27, column 12 is not reachable after line 38, column 13.
Showing all 95 steps of the trace


engines/ccgost/gost_pmeth.c:22:1: start of procedure pkey_gost_init()
20.   /* -----init, cleanup, copy - uniform for all algs  ---------------*/
21.   /* Allocates new gost_pmeth_data structure and assigns it as data */
22. > static int pkey_gost_init(EVP_PKEY_CTX *ctx)
23.   {
24.       struct gost_pmeth_data *data;

engines/ccgost/gost_pmeth.c:25:5: 
23.   {
24.       struct gost_pmeth_data *data;
25. >     EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(ctx);
26.   
27.       data = OPENSSL_zalloc(sizeof(*data));

crypto/evp/pmeth_lib.c:411:1: start of procedure EVP_PKEY_CTX_get0_pkey()
  409.   }
  410.   
  411. > EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx)
  412.   {
  413.       return ctx->pkey;

crypto/evp/pmeth_lib.c:413:5: 
  411.   EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx)
  412.   {
  413. >     return ctx->pkey;
  414.   }
  415.   

crypto/evp/pmeth_lib.c:414:1: return from a call to EVP_PKEY_CTX_get0_pkey
  412.   {
  413.       return ctx->pkey;
  414. > }
  415.   
  416.   EVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx)

engines/ccgost/gost_pmeth.c:27:5: 
25.       EVP_PKEY *pkey = EVP_PKEY_CTX_get0_pkey(ctx);
26.   
27. >     data = OPENSSL_zalloc(sizeof(*data));
28.       if (!data)
29.           return 0;

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.   #ifndef OPENSSL_NO_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)

engines/ccgost/gost_pmeth.c:28:10: Taking false branch
26.   
27.       data = OPENSSL_zalloc(sizeof(*data));
28.       if (!data)
               ^
29.           return 0;
30.       if (pkey && EVP_PKEY_get0(pkey)) {

engines/ccgost/gost_pmeth.c:30:9: Taking true branch
28.       if (!data)
29.           return 0;
30.       if (pkey && EVP_PKEY_get0(pkey)) {
              ^
31.           switch (EVP_PKEY_base_id(pkey)) {
32.           case NID_id_GostR3410_2001:

engines/ccgost/gost_pmeth.c:30:17: 
28.       if (!data)
29.           return 0;
30. >     if (pkey && EVP_PKEY_get0(pkey)) {
31.           switch (EVP_PKEY_base_id(pkey)) {
32.           case NID_id_GostR3410_2001:

crypto/evp/p_lib.c:278:1: start of procedure EVP_PKEY_get0()
  276.   }
  277.   
  278. > void *EVP_PKEY_get0(EVP_PKEY *pkey)
  279.   {
  280.       return pkey->pkey.ptr;

crypto/evp/p_lib.c:280:5: 
  278.   void *EVP_PKEY_get0(EVP_PKEY *pkey)
  279.   {
  280. >     return pkey->pkey.ptr;
  281.   }
  282.   

crypto/evp/p_lib.c:281:1: return from a call to EVP_PKEY_get0
  279.   {
  280.       return pkey->pkey.ptr;
  281. > }
  282.   
  283.   #ifndef OPENSSL_NO_RSA

engines/ccgost/gost_pmeth.c:30:17: Taking true branch
28.       if (!data)
29.           return 0;
30.       if (pkey && EVP_PKEY_get0(pkey)) {
                      ^
31.           switch (EVP_PKEY_base_id(pkey)) {
32.           case NID_id_GostR3410_2001:

engines/ccgost/gost_pmeth.c:31:9: 
29.           return 0;
30.       if (pkey && EVP_PKEY_get0(pkey)) {
31. >         switch (EVP_PKEY_base_id(pkey)) {
32.           case NID_id_GostR3410_2001:
33.               data->sign_param_nid =

crypto/evp/p_lib.c:415:1: start of procedure EVP_PKEY_base_id()
  413.   }
  414.   
  415. > int EVP_PKEY_base_id(const EVP_PKEY *pkey)
  416.   {
  417.       return EVP_PKEY_type(pkey->type);

crypto/evp/p_lib.c:417:5: 
  415.   int EVP_PKEY_base_id(const EVP_PKEY *pkey)
  416.   {
  417. >     return EVP_PKEY_type(pkey->type);
  418.   }
  419.   

crypto/evp/p_lib.c:393:1: start of procedure EVP_PKEY_type()
    391.   #endif
    392.   
    393. > int EVP_PKEY_type(int type)
    394.   {
    395.       int ret;

crypto/evp/p_lib.c:398:5: 
    396.       const EVP_PKEY_ASN1_METHOD *ameth;
    397.       ENGINE *e;
    398. >     ameth = EVP_PKEY_asn1_find(&e, type);
    399.       if (ameth)
    400.           ret = ameth->pkey_id;

crypto/asn1/ameth_lib.c:162:1: start of procedure EVP_PKEY_asn1_find()
      160.    */
      161.   
      162. > const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type)
      163.   {
      164.       const EVP_PKEY_ASN1_METHOD *t;

crypto/asn1/ameth_lib.c:171:5: Loop condition is true. Entering loop body
      169.               break;
      170.           type = t->pkey_base_id;
      171.       }
                 ^
      172.       if (pe) {
      173.   #ifndef OPENSSL_NO_ENGINE

crypto/asn1/ameth_lib.c:167:9: 
      165.   
      166.       for (;;) {
      167. >         t = pkey_asn1_find(type);
      168.           if (!t || !(t->pkey_flags & ASN1_PKEY_ALIAS))
      169.               break;

crypto/asn1/ameth_lib.c:139:1: start of procedure pkey_asn1_find()
        137.   }
        138.   
        139. > static const EVP_PKEY_ASN1_METHOD *pkey_asn1_find(int type)
        140.   {
        141.       EVP_PKEY_ASN1_METHOD tmp;

crypto/asn1/ameth_lib.c:142:5: 
        140.   {
        141.       EVP_PKEY_ASN1_METHOD tmp;
        142. >     const EVP_PKEY_ASN1_METHOD *t = &tmp, **ret;
        143.       tmp.pkey_id = type;
        144.       if (app_methods) {

crypto/asn1/ameth_lib.c:143:5: 
        141.       EVP_PKEY_ASN1_METHOD tmp;
        142.       const EVP_PKEY_ASN1_METHOD *t = &tmp, **ret;
        143. >     tmp.pkey_id = type;
        144.       if (app_methods) {
        145.           int idx;

crypto/asn1/ameth_lib.c:144:9: Taking true branch
        142.       const EVP_PKEY_ASN1_METHOD *t = &tmp, **ret;
        143.       tmp.pkey_id = type;
        144.       if (app_methods) {
                       ^
        145.           int idx;
        146.           idx = sk_EVP_PKEY_ASN1_METHOD_find(app_methods, &tmp);

crypto/asn1/ameth_lib.c:146:9: 
        144.       if (app_methods) {
        145.           int idx;
        146. >         idx = sk_EVP_PKEY_ASN1_METHOD_find(app_methods, &tmp);
        147.           if (idx >= 0)
        148.               return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);

crypto/include/internal/asn1_int.h:107:1: start of procedure sk_EVP_PKEY_ASN1_METHOD_find()
          105.   } /* EVP_PKEY_ASN1_METHOD */ ;
          106.   
          107. > DEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD)
          108.   
          109.   extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth;

crypto/stack/stack.c:249:1: start of procedure sk_find()
            247.   }
            248.   
            249. > int sk_find(_STACK *st, void *data)
            250.   {
            251.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);

crypto/stack/stack.c:251:5: 
            249.   int sk_find(_STACK *st, void *data)
            250.   {
            251. >     return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
            252.   }
            253.   

crypto/stack/stack.c:225:1: start of procedure internal_find()
              223.   }
              224.   
              225. > static int internal_find(_STACK *st, void *data, int ret_val_options)
              226.   {
              227.       const void *const *r;

crypto/stack/stack.c:230:9: Taking false branch
              228.       int i;
              229.   
              230.       if (st == NULL)
                             ^
              231.           return -1;
              232.   

crypto/stack/stack.c:233:9: Taking true branch
              231.           return -1;
              232.   
              233.       if (st->comp == NULL) {
                             ^
              234.           for (i = 0; i < st->num; i++)
              235.               if (st->data[i] == data)

crypto/stack/stack.c:234:14: 
              232.   
              233.       if (st->comp == NULL) {
              234. >         for (i = 0; i < st->num; i++)
              235.               if (st->data[i] == data)
              236.                   return (i);

crypto/stack/stack.c:234:21: Loop condition is true. Entering loop body
              232.   
              233.       if (st->comp == NULL) {
              234.           for (i = 0; i < st->num; i++)
                                         ^
              235.               if (st->data[i] == data)
              236.                   return (i);

crypto/stack/stack.c:235:17: Taking false branch
              233.       if (st->comp == NULL) {
              234.           for (i = 0; i < st->num; i++)
              235.               if (st->data[i] == data)
                                     ^
              236.                   return (i);
              237.           return (-1);

crypto/stack/stack.c:234:34: 
              232.   
              233.       if (st->comp == NULL) {
              234. >         for (i = 0; i < st->num; i++)
              235.               if (st->data[i] == data)
              236.                   return (i);

crypto/stack/stack.c:234:21: Loop condition is true. Entering loop body
              232.   
              233.       if (st->comp == NULL) {
              234.           for (i = 0; i < st->num; i++)
                                         ^
              235.               if (st->data[i] == data)
              236.                   return (i);

crypto/stack/stack.c:235:17: Taking true branch
              233.       if (st->comp == NULL) {
              234.           for (i = 0; i < st->num; i++)
              235.               if (st->data[i] == data)
                                     ^
              236.                   return (i);
              237.           return (-1);

crypto/stack/stack.c:236:17: 
              234.           for (i = 0; i < st->num; i++)
              235.               if (st->data[i] == data)
              236. >                 return (i);
              237.           return (-1);
              238.       }

crypto/stack/stack.c:247:1: return from a call to internal_find
              245.           return (-1);
              246.       return (int)((char **)r - st->data);
              247. > }
              248.   
              249.   int sk_find(_STACK *st, void *data)

crypto/stack/stack.c:252:1: return from a call to sk_find
            250.   {
            251.       return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH);
            252. > }
            253.   
            254.   int sk_find_ex(_STACK *st, void *data)

crypto/include/internal/asn1_int.h:107:1: return from a call to sk_EVP_PKEY_ASN1_METHOD_find
          105.   } /* EVP_PKEY_ASN1_METHOD */ ;
          106.   
          107. > DEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD)
          108.   
          109.   extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth;

crypto/asn1/ameth_lib.c:147:13: Taking true branch
        145.           int idx;
        146.           idx = sk_EVP_PKEY_ASN1_METHOD_find(app_methods, &tmp);
        147.           if (idx >= 0)
                           ^
        148.               return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
        149.       }

crypto/asn1/ameth_lib.c:148:13: 
        146.           idx = sk_EVP_PKEY_ASN1_METHOD_find(app_methods, &tmp);
        147.           if (idx >= 0)
        148. >             return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
        149.       }
        150.       ret = OBJ_bsearch_ameth(&t, standard_methods, OSSL_NELEM(standard_methods));

crypto/include/internal/asn1_int.h:107:1: start of procedure sk_EVP_PKEY_ASN1_METHOD_value()
          105.   } /* EVP_PKEY_ASN1_METHOD */ ;
          106.   
          107. > DEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD)
          108.   
          109.   extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth;

crypto/stack/stack.c:324:1: start of procedure sk_value()
            322.   }
            323.   
            324. > void *sk_value(const _STACK *st, int i)
            325.   {
            326.       if (!st || (i < 0) || (i >= st->num))

crypto/stack/stack.c:326:10: Taking false branch
            324.   void *sk_value(const _STACK *st, int i)
            325.   {
            326.       if (!st || (i < 0) || (i >= st->num))
                            ^
            327.           return NULL;
            328.       return st->data[i];

crypto/stack/stack.c:326:17: Taking false branch
            324.   void *sk_value(const _STACK *st, int i)
            325.   {
            326.       if (!st || (i < 0) || (i >= st->num))
                                   ^
            327.           return NULL;
            328.       return st->data[i];

crypto/stack/stack.c:326:28: Taking false branch
            324.   void *sk_value(const _STACK *st, int i)
            325.   {
            326.       if (!st || (i < 0) || (i >= st->num))
                                              ^
            327.           return NULL;
            328.       return st->data[i];

crypto/stack/stack.c:328:5: 
            326.       if (!st || (i < 0) || (i >= st->num))
            327.           return NULL;
            328. >     return st->data[i];
            329.   }
            330.   

crypto/stack/stack.c:329:1: return from a call to sk_value
            327.           return NULL;
            328.       return st->data[i];
            329. > }
            330.   
            331.   void *sk_set(_STACK *st, int i, void *value)

crypto/include/internal/asn1_int.h:107:1: return from a call to sk_EVP_PKEY_ASN1_METHOD_value
          105.   } /* EVP_PKEY_ASN1_METHOD */ ;
          106.   
          107. > DEFINE_STACK_OF_CONST(EVP_PKEY_ASN1_METHOD)
          108.   
          109.   extern const EVP_PKEY_ASN1_METHOD cmac_asn1_meth;

crypto/asn1/ameth_lib.c:154:1: return from a call to pkey_asn1_find
        152.           return NULL;
        153.       return *ret;
        154. > }
        155.   
        156.   /*

crypto/asn1/ameth_lib.c:168:14: Taking false branch
      166.       for (;;) {
      167.           t = pkey_asn1_find(type);
      168.           if (!t || !(t->pkey_flags & ASN1_PKEY_ALIAS))
                          ^
      169.               break;
      170.           type = t->pkey_base_id;

crypto/asn1/ameth_lib.c:168:21: Taking true branch
      166.       for (;;) {
      167.           t = pkey_asn1_find(type);
      168.           if (!t || !(t->pkey_flags & ASN1_PKEY_ALIAS))
                                 ^
      169.               break;
      170.           type = t->pkey_base_id;

crypto/asn1/ameth_lib.c:172:9: Taking true branch
      170.           type = t->pkey_base_id;
      171.       }
      172.       if (pe) {
                     ^
      173.   #ifndef OPENSSL_NO_ENGINE
      174.           ENGINE *e;

crypto/asn1/ameth_lib.c:176:9: 
      174.           ENGINE *e;
      175.           /* type will contain the final unaliased type */
      176. >         e = ENGINE_get_pkey_asn1_meth_engine(type);
      177.           if (e) {
      178.               *pe = e;

crypto/engine/tb_asnmth.c:118:1: start of procedure ENGINE_get_pkey_asn1_meth_engine()
        116.    * references) for a given pkey_asn1_meth 'nid'
        117.    */
        118. > ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid)
        119.   {
        120.       return engine_table_select(&pkey_asn1_meth_table, nid);

crypto/engine/tb_asnmth.c:120:5: 
        118.   ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid)
        119.   {
        120. >     return engine_table_select(&pkey_asn1_meth_table, nid);
        121.   }
        122.   

crypto/engine/eng_table.c:243:1: start of procedure engine_table_select()
          241.   /* return a functional reference for a given 'nid' */
          242.   #ifndef ENGINE_TABLE_DEBUG
          243. > ENGINE *engine_table_select(ENGINE_TABLE **table, int nid)
          244.   #else
          245.   ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,

crypto/engine/eng_table.c:249:5: 
          247.   #endif
          248.   {
          249. >     ENGINE *ret = NULL;
          250.       ENGINE_PILE tmplate, *fnd = NULL;
          251.       int initres, loop = 0;

crypto/engine/eng_table.c:250:5: 
          248.   {
          249.       ENGINE *ret = NULL;
          250. >     ENGINE_PILE tmplate, *fnd = NULL;
          251.       int initres, loop = 0;
          252.   

crypto/engine/eng_table.c:251:5: 
          249.       ENGINE *ret = NULL;
          250.       ENGINE_PILE tmplate, *fnd = NULL;
          251. >     int initres, loop = 0;
          252.   
          253.       if (!(*table)) {

crypto/engine/eng_table.c:253:11: 
          251.       int initres, loop = 0;
          252.   
          253. >     if (!(*table)) {
          254.   #ifdef ENGINE_TABLE_DEBUG
          255.           fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, nothing "

crypto/engine/eng_table.c:253:10: Taking true branch
          251.       int initres, loop = 0;
          252.   
          253.       if (!(*table)) {
                          ^
          254.   #ifdef ENGINE_TABLE_DEBUG
          255.           fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, nothing "

crypto/engine/eng_table.c:258:9: 
          256.                   "registered!\n", f, l, nid);
          257.   #endif
          258. >         return NULL;
          259.       }
          260.       ERR_set_mark();

crypto/engine/eng_table.c:339:1: return from a call to engine_table_select
          337.       ERR_pop_to_mark();
          338.       return ret;
          339. > }
          340.   
          341.   /* Table enumeration */

crypto/engine/tb_asnmth.c:121:1: return from a call to ENGINE_get_pkey_asn1_meth_engine
        119.   {
        120.       return engine_table_select(&pkey_asn1_meth_table, nid);
        121. > }
        122.   
        123.   /*

crypto/asn1/ameth_lib.c:177:13: Taking false branch
      175.           /* type will contain the final unaliased type */
      176.           e = ENGINE_get_pkey_asn1_meth_engine(type);
      177.           if (e) {
                         ^
      178.               *pe = e;
      179.               return ENGINE_get_pkey_asn1_meth(e, type);

crypto/asn1/ameth_lib.c:182:9: 
      180.           }
      181.   #endif
      182. >         *pe = NULL;
      183.       }
      184.       return t;

crypto/asn1/ameth_lib.c:184:5: 
      182.           *pe = NULL;
      183.       }
      184. >     return t;
      185.   }
      186.   

crypto/asn1/ameth_lib.c:185:1: return from a call to EVP_PKEY_asn1_find
      183.       }
      184.       return t;
      185. > }
      186.   
      187.   const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,

crypto/evp/p_lib.c:399:9: Taking true branch
    397.       ENGINE *e;
    398.       ameth = EVP_PKEY_asn1_find(&e, type);
    399.       if (ameth)
                   ^
    400.           ret = ameth->pkey_id;
    401.       else

crypto/evp/p_lib.c:400:9: 
    398.       ameth = EVP_PKEY_asn1_find(&e, type);
    399.       if (ameth)
    400. >         ret = ameth->pkey_id;
    401.       else
    402.           ret = NID_undef;

crypto/evp/p_lib.c:404:9: Taking false branch
    402.           ret = NID_undef;
    403.   #ifndef OPENSSL_NO_ENGINE
    404.       if (e)
                   ^
    405.           ENGINE_finish(e);
    406.   #endif

crypto/evp/p_lib.c:407:5: 
    405.           ENGINE_finish(e);
    406.   #endif
    407. >     return ret;
    408.   }
    409.   

crypto/evp/p_lib.c:408:1: return from a call to EVP_PKEY_type
    406.   #endif
    407.       return ret;
    408. > }
    409.   
    410.   int EVP_PKEY_id(const EVP_PKEY *pkey)

crypto/evp/p_lib.c:418:1: return from a call to EVP_PKEY_base_id
  416.   {
  417.       return EVP_PKEY_type(pkey->type);
  418. > }
  419.   
  420.   void EVP_PKEY_free(EVP_PKEY *x)

engines/ccgost/gost_pmeth.c:32:9: Switch condition is false. Skipping switch case
30.       if (pkey && EVP_PKEY_get0(pkey)) {
31.           switch (EVP_PKEY_base_id(pkey)) {
32.           case NID_id_GostR3410_2001:
              ^
33.               data->sign_param_nid =
34.                   EC_GROUP_get_curve_name(EC_KEY_get0_group

engines/ccgost/gost_pmeth.c:38:13: 
36.               break;
37.           default:
38. >             return 0;
39.           }
40.       }
