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


crypto/bio/b_addr.c:587:1: start of procedure addrinfo_wrap()
585.    * only happens if a memory allocation error occurred.
586.    */
587. > static int addrinfo_wrap(int family, int socktype,
588.                            const void *where, size_t wherelen,
589.                            unsigned short port,

crypto/bio/b_addr.c:592:5: Condition is true
590.                            BIO_ADDRINFO **bai)
591.   {
592.       OPENSSL_assert(bai != NULL);
           ^
593.   
594.       *bai = OPENSSL_zalloc(sizeof(**bai));

crypto/bio/b_addr.c:594:5: 
592.       OPENSSL_assert(bai != NULL);
593.   
594. >     *bai = OPENSSL_zalloc(sizeof(**bai));
595.       if (*bai == NULL)
596.           return 0;

crypto/mem.c:98:1: start of procedure CRYPTO_zalloc()
  96.   }
  97.   
  98. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  99.   {
  100.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:100:5: 
  98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  99.   {
  100. >     void *ret = CRYPTO_malloc(num, file, line);
  101.   
  102.       if (ret != NULL)

crypto/mem.c:71:1: start of procedure CRYPTO_malloc()
    69.   }
    70.   
    71. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    72.   {
    73.       void *ret = NULL;

crypto/mem.c:73:5: 
    71.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    72.   {
    73. >     void *ret = NULL;
    74.   
    75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:75:9: Taking false branch
    73.       void *ret = NULL;
    74.   
    75.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                  ^
    76.           return malloc_impl(num, file, line);
    77.   

crypto/mem.c:78:9: Taking false branch
    76.           return malloc_impl(num, file, line);
    77.   
    78.       if (num <= 0)
                  ^
    79.           return NULL;
    80.   

crypto/mem.c:81:5: 
    79.           return NULL;
    80.   
    81. >     allow_customize = 0;
    82.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    83.       if (call_malloc_debug) {

crypto/mem.c:91:5: 
    89.       }
    90.   #else
    91. >     osslargused(file); osslargused(line);
    92.       ret = malloc(num);
    93.   #endif

crypto/mem.c:91:24: 
    89.       }
    90.   #else
    91. >     osslargused(file); osslargused(line);
    92.       ret = malloc(num);
    93.   #endif

crypto/mem.c:92:5: 
    90.   #else
    91.       osslargused(file); osslargused(line);
    92. >     ret = malloc(num);
    93.   #endif
    94.   

crypto/mem.c:95:5: 
    93.   #endif
    94.   
    95. >     return ret;
    96.   }
    97.   

crypto/mem.c:96:1: return from a call to CRYPTO_malloc
    94.   
    95.       return ret;
    96. > }
    97.   
    98.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:102:9: Taking true branch
  100.       void *ret = CRYPTO_malloc(num, file, line);
  101.   
  102.       if (ret != NULL)
                 ^
  103.           memset(ret, 0, num);
  104.       return ret;

crypto/mem.c:103:9: 
  101.   
  102.       if (ret != NULL)
  103. >         memset(ret, 0, num);
  104.       return ret;
  105.   }

crypto/mem.c:104:5: 
  102.       if (ret != NULL)
  103.           memset(ret, 0, num);
  104. >     return ret;
  105.   }
  106.   

crypto/mem.c:105:1: return from a call to CRYPTO_zalloc
  103.           memset(ret, 0, num);
  104.       return ret;
  105. > }
  106.   
  107.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/bio/b_addr.c:595:9: Taking false branch
593.   
594.       *bai = OPENSSL_zalloc(sizeof(**bai));
595.       if (*bai == NULL)
               ^
596.           return 0;
597.   

crypto/bio/b_addr.c:598:5: 
596.           return 0;
597.   
598. >     (*bai)->bai_family = family;
599.       (*bai)->bai_socktype = socktype;
600.       if (socktype == SOCK_STREAM)

crypto/bio/b_addr.c:599:5: 
597.   
598.       (*bai)->bai_family = family;
599. >     (*bai)->bai_socktype = socktype;
600.       if (socktype == SOCK_STREAM)
601.           (*bai)->bai_protocol = IPPROTO_TCP;

crypto/bio/b_addr.c:600:9: Taking false branch
598.       (*bai)->bai_family = family;
599.       (*bai)->bai_socktype = socktype;
600.       if (socktype == SOCK_STREAM)
               ^
601.           (*bai)->bai_protocol = IPPROTO_TCP;
602.       if (socktype == SOCK_DGRAM)

crypto/bio/b_addr.c:602:9: Taking false branch
600.       if (socktype == SOCK_STREAM)
601.           (*bai)->bai_protocol = IPPROTO_TCP;
602.       if (socktype == SOCK_DGRAM)
               ^
603.           (*bai)->bai_protocol = IPPROTO_UDP;
604.   #ifdef AF_UNIX

crypto/bio/b_addr.c:605:9: Taking false branch
603.           (*bai)->bai_protocol = IPPROTO_UDP;
604.   #ifdef AF_UNIX
605.       if (family == AF_UNIX)
               ^
606.           (*bai)->bai_protocol = 0;
607.   #endif

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

crypto/bio/b_addr.c:615:13: Taking false branch
613.              all right. */
614.           BIO_ADDR *addr = BIO_ADDR_new();
615.           if (addr != NULL) {
                   ^
616.               BIO_ADDR_rawmake(addr, family, where, wherelen, port);
617.               (*bai)->bai_addr = BIO_ADDR_sockaddr_noconst(addr);

crypto/bio/b_addr.c:620:5: 
618.           }
619.       }
620. >     (*bai)->bai_next = NULL;
621.       if ((*bai)->bai_addr == NULL) {
622.           BIO_ADDRINFO_free(*bai);

crypto/bio/b_addr.c:621:9: Taking true branch
619.       }
620.       (*bai)->bai_next = NULL;
621.       if ((*bai)->bai_addr == NULL) {
               ^
622.           BIO_ADDRINFO_free(*bai);
623.           *bai = NULL;

crypto/bio/b_addr.c:622:9: Skipping BIO_ADDRINFO_free(): empty list of specs
620.       (*bai)->bai_next = NULL;
621.       if ((*bai)->bai_addr == NULL) {
622.           BIO_ADDRINFO_free(*bai);
               ^
623.           *bai = NULL;
624.           return 0;

crypto/bio/b_addr.c:623:9: 
621.       if ((*bai)->bai_addr == NULL) {
622.           BIO_ADDRINFO_free(*bai);
623. >         *bai = NULL;
624.           return 0;
625.       }

static int addrinfo_wrap(int family, int socktype,
                         const void *where, size_t wherelen,
                         unsigned short port,
                         BIO_ADDRINFO **bai)
{
    OPENSSL_assert(bai != NULL);
    *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    OPENSSL_assert(bai != NULL);\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    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 (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\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    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}']