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


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

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

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

crypto/mem.c:146:1: start of procedure CRYPTO_zalloc()
  144.   }
  145.   
  146. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
  147.   {
  148.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:148:5: 
  146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
  147.   {
  148. >     void *ret = CRYPTO_malloc(num, file, line);
  149.   
  150.       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 (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking false branch
    121.       void *ret = NULL;
    122.   
    123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    124.           return malloc_impl(num, file, line);
    125.   

crypto/mem.c:126:9: Taking false branch
    124.           return malloc_impl(num, file, line);
    125.   
    126.       if (num <= 0)
                   ^
    127.           return NULL;
    128.   

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

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

crypto/mem.c:139:24: 
    137.       }
    138.   #else
    139. >     osslargused(file); osslargused(line);
    140.       ret = malloc(num);
    141.   #endif

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

crypto/mem.c:143:5: 
    141.   #endif
    142.   
    143. >     return ret;
    144.   }
    145.   

crypto/mem.c:144:1: return from a call to CRYPTO_malloc
    142.   
    143.       return ret;
    144. > }
    145.   
    146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:150:9: Taking true branch
  148.       void *ret = CRYPTO_malloc(num, file, line);
  149.   
  150.       if (ret != NULL)
                 ^
  151.           memset(ret, 0, num);
  152.       return ret;

crypto/mem.c:151:9: 
  149.   
  150.       if (ret != NULL)
  151. >         memset(ret, 0, num);
  152.       return ret;
  153.   }

crypto/mem.c:152:5: 
  150.       if (ret != NULL)
  151.           memset(ret, 0, num);
  152. >     return ret;
  153.   }
  154.   

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

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

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

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

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

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

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

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

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

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

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

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

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

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}']