crypto/bio/b_addr.c:597: error: MEMORY_LEAK
  memory dynamically allocated to `*bai` by call to `CRYPTO_zalloc()` at line 568, column 12 is not reachable after line 597, column 9.
Showing all 30 steps of the trace


crypto/bio/b_addr.c:563:1: start of procedure addrinfo_wrap()
561.    * only happens if a memory allocation error occurred.
562.    */
563. > static int addrinfo_wrap(int family, int socktype,
564.                            const void *where, size_t wherelen,
565.                            unsigned short port,

crypto/bio/b_addr.c:568:5: 
566.                            BIO_ADDRINFO **bai)
567.   {
568. >     *bai = OPENSSL_zalloc(sizeof(**bai));
569.       if (*bai == NULL)
570.           return 0;

crypto/mem.c:218:1: start of procedure CRYPTO_zalloc()
  216.   }
  217.   
  218. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  219.   {
  220.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:220:5: 
  218.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  219.   {
  220. >     void *ret = CRYPTO_malloc(num, file, line);
  221.   
  222.       FAILTEST();

crypto/mem.c:189:1: start of procedure CRYPTO_malloc()
    187.   #endif
    188.   
    189. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    190.   {
    191.       void *ret = NULL;

crypto/mem.c:191:5: 
    189.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    190.   {
    191. >     void *ret = NULL;
    192.   
    193.       INCREMENT(malloc_count);

crypto/mem.c:194:9: Taking false branch
    192.   
    193.       INCREMENT(malloc_count);
    194.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    195.           return malloc_impl(num, file, line);
    196.   

crypto/mem.c:197:9: Taking false branch
    195.           return malloc_impl(num, file, line);
    196.   
    197.       if (num == 0)
                   ^
    198.           return NULL;
    199.   

crypto/mem.c:201:5: 
    199.   
    200.       FAILTEST();
    201. >     allow_customize = 0;
    202.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    203.       if (call_malloc_debug) {

crypto/mem.c:211:5: 
    209.       }
    210.   #else
    211. >     (void)(file); (void)(line);
    212.       ret = malloc(num);
    213.   #endif

crypto/mem.c:211:19: 
    209.       }
    210.   #else
    211. >     (void)(file); (void)(line);
    212.       ret = malloc(num);
    213.   #endif

crypto/mem.c:212:5: 
    210.   #else
    211.       (void)(file); (void)(line);
    212. >     ret = malloc(num);
    213.   #endif
    214.   

crypto/mem.c:215:5: 
    213.   #endif
    214.   
    215. >     return ret;
    216.   }
    217.   

crypto/mem.c:216:1: return from a call to CRYPTO_malloc
    214.   
    215.       return ret;
    216. > }
    217.   
    218.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:223:9: Taking true branch
  221.   
  222.       FAILTEST();
  223.       if (ret != NULL)
                 ^
  224.           memset(ret, 0, num);
  225.       return ret;

crypto/mem.c:224:9: 
  222.       FAILTEST();
  223.       if (ret != NULL)
  224. >         memset(ret, 0, num);
  225.       return ret;
  226.   }

crypto/mem.c:225:5: 
  223.       if (ret != NULL)
  224.           memset(ret, 0, num);
  225. >     return ret;
  226.   }
  227.   

crypto/mem.c:226:1: return from a call to CRYPTO_zalloc
  224.           memset(ret, 0, num);
  225.       return ret;
  226. > }
  227.   
  228.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/bio/b_addr.c:569:9: Taking false branch
567.   {
568.       *bai = OPENSSL_zalloc(sizeof(**bai));
569.       if (*bai == NULL)
               ^
570.           return 0;
571.   

crypto/bio/b_addr.c:572:5: 
570.           return 0;
571.   
572. >     (*bai)->bai_family = family;
573.       (*bai)->bai_socktype = socktype;
574.       if (socktype == SOCK_STREAM)

crypto/bio/b_addr.c:573:5: 
571.   
572.       (*bai)->bai_family = family;
573. >     (*bai)->bai_socktype = socktype;
574.       if (socktype == SOCK_STREAM)
575.           (*bai)->bai_protocol = IPPROTO_TCP;

crypto/bio/b_addr.c:574:9: Taking false branch
572.       (*bai)->bai_family = family;
573.       (*bai)->bai_socktype = socktype;
574.       if (socktype == SOCK_STREAM)
               ^
575.           (*bai)->bai_protocol = IPPROTO_TCP;
576.       if (socktype == SOCK_DGRAM)

crypto/bio/b_addr.c:576:9: Taking false branch
574.       if (socktype == SOCK_STREAM)
575.           (*bai)->bai_protocol = IPPROTO_TCP;
576.       if (socktype == SOCK_DGRAM)
               ^
577.           (*bai)->bai_protocol = IPPROTO_UDP;
578.   #ifdef AF_UNIX

crypto/bio/b_addr.c:579:9: Taking false branch
577.           (*bai)->bai_protocol = IPPROTO_UDP;
578.   #ifdef AF_UNIX
579.       if (family == AF_UNIX)
               ^
580.           (*bai)->bai_protocol = 0;
581.   #endif

crypto/bio/b_addr.c:588:9: Skipping BIO_ADDR_new(): empty list of specs
586.              creating a memory leak here, we are not.  It will be
587.              all right. */
588.           BIO_ADDR *addr = BIO_ADDR_new();
               ^
589.           if (addr != NULL) {
590.               BIO_ADDR_rawmake(addr, family, where, wherelen, port);

crypto/bio/b_addr.c:589:13: Taking false branch
587.              all right. */
588.           BIO_ADDR *addr = BIO_ADDR_new();
589.           if (addr != NULL) {
                   ^
590.               BIO_ADDR_rawmake(addr, family, where, wherelen, port);
591.               (*bai)->bai_addr = BIO_ADDR_sockaddr_noconst(addr);

crypto/bio/b_addr.c:594:5: 
592.           }
593.       }
594. >     (*bai)->bai_next = NULL;
595.       if ((*bai)->bai_addr == NULL) {
596.           BIO_ADDRINFO_free(*bai);

crypto/bio/b_addr.c:595:9: Taking true branch
593.       }
594.       (*bai)->bai_next = NULL;
595.       if ((*bai)->bai_addr == NULL) {
               ^
596.           BIO_ADDRINFO_free(*bai);
597.           *bai = NULL;

crypto/bio/b_addr.c:596:9: Skipping BIO_ADDRINFO_free(): empty list of specs
594.       (*bai)->bai_next = NULL;
595.       if ((*bai)->bai_addr == NULL) {
596.           BIO_ADDRINFO_free(*bai);
               ^
597.           *bai = NULL;
598.           return 0;

crypto/bio/b_addr.c:597:9: 
595.       if ((*bai)->bai_addr == NULL) {
596.           BIO_ADDRINFO_free(*bai);
597. >         *bai = NULL;
598.           return 0;
599.       }

static int addrinfo_wrap(int family, int socktype,
                         const void *where, size_t wherelen,
                         unsigned short port,
                         BIO_ADDRINFO **bai)
{
    *bai = OPENSSL_zalloc(sizeof(**bai));
    if (*bai == NULL)
        return 0;
    (*bai)->bai_family = family;
    (*bai)->bai_socktype = socktype;
    if (socktype == SOCK_STREAM)
        (*bai)->bai_protocol = IPPROTO_TCP;
    if (socktype == SOCK_DGRAM)
        (*bai)->bai_protocol = IPPROTO_UDP;
#ifdef AF_UNIX
    if (family == AF_UNIX)
        (*bai)->bai_protocol = 0;
#endif
    {
        BIO_ADDR *addr = BIO_ADDR_new();
        if (addr != NULL) {
            BIO_ADDR_rawmake(addr, family, where, wherelen, port);
            (*bai)->bai_addr = BIO_ADDR_sockaddr_noconst(addr);
        }
    }
    (*bai)->bai_next = NULL;
    if ((*bai)->bai_addr == NULL) {
        BIO_ADDRINFO_free(*bai);
        *bai = NULL;
        return 0;
    }
    return 1;
}
['static int addrinfo_wrap(int family, int socktype,\n                         const void *where, size_t wherelen,\n                         unsigned short port,\n                         BIO_ADDRINFO **bai)\n{\n    *bai = OPENSSL_zalloc(sizeof(**bai));\n    if (*bai == NULL)\n        return 0;\n    (*bai)->bai_family = family;\n    (*bai)->bai_socktype = socktype;\n    if (socktype == SOCK_STREAM)\n        (*bai)->bai_protocol = IPPROTO_TCP;\n    if (socktype == SOCK_DGRAM)\n        (*bai)->bai_protocol = IPPROTO_UDP;\n#ifdef AF_UNIX\n    if (family == AF_UNIX)\n        (*bai)->bai_protocol = 0;\n#endif\n    {\n        BIO_ADDR *addr = BIO_ADDR_new();\n        if (addr != NULL) {\n            BIO_ADDR_rawmake(addr, family, where, wherelen, port);\n            (*bai)->bai_addr = BIO_ADDR_sockaddr_noconst(addr);\n        }\n    }\n    (*bai)->bai_next = NULL;\n    if ((*bai)->bai_addr == NULL) {\n        BIO_ADDRINFO_free(*bai);\n        *bai = NULL;\n        return 0;\n    }\n    return 1;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\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    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\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); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}']