ssl/ssl_txt.c:53: error: MEMORY_LEAK
  memory dynamically allocated by call to `BIO_new()` at line 47, column 14 is not reachable after line 53, column 5.
Showing all 48 steps of the trace


ssl/ssl_txt.c:42:1: start of procedure SSL_SESSION_print_fp()
40.   
41.   #ifndef OPENSSL_NO_STDIO
42. > int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *x)
43.   {
44.       BIO *b;

ssl/ssl_txt.c:47:9: 
45.       int ret;
46.   
47. >     if ((b = BIO_new(BIO_s_file())) == NULL) {
48.           SSLerr(SSL_F_SSL_SESSION_PRINT_FP, ERR_R_BUF_LIB);
49.           return (0);

crypto/bio/bss_file.c:106:1: start of procedure BIO_s_file()
  104.   }
  105.   
  106. > const BIO_METHOD *BIO_s_file(void)
  107.   {
  108.       return (&methods_filep);

crypto/bio/bss_file.c:108:5: 
  106.   const BIO_METHOD *BIO_s_file(void)
  107.   {
  108. >     return (&methods_filep);
  109.   }
  110.   

crypto/bio/bss_file.c:109:1: return from a call to BIO_s_file
  107.   {
  108.       return (&methods_filep);
  109. > }
  110.   
  111.   static int file_new(BIO *bi)

crypto/bio/bio_lib.c:17:1: start of procedure BIO_new()
  15.   #include <openssl/stack.h>
  16.   
  17. > BIO *BIO_new(const BIO_METHOD *method)
  18.   {
  19.       BIO *ret = OPENSSL_malloc(sizeof(*ret));

crypto/bio/bio_lib.c:19:5: 
  17.   BIO *BIO_new(const BIO_METHOD *method)
  18.   {
  19. >     BIO *ret = OPENSSL_malloc(sizeof(*ret));
  20.   
  21.       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/bio/bio_lib.c:21:9: Taking false branch
  19.       BIO *ret = OPENSSL_malloc(sizeof(*ret));
  20.   
  21.       if (ret == NULL) {
                ^
  22.           BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
  23.           return (NULL);

crypto/bio/bio_lib.c:25:10: Taking false branch
  23.           return (NULL);
  24.       }
  25.       if (!BIO_set(ret, method)) {
                 ^
  26.           OPENSSL_free(ret);
  27.           ret = NULL;

crypto/bio/bio_lib.c:29:5: 
  27.           ret = NULL;
  28.       }
  29. >     return (ret);
  30.   }
  31.   

crypto/bio/bio_lib.c:30:1: return from a call to BIO_new
  28.       }
  29.       return (ret);
  30. > }
  31.   
  32.   int BIO_set(BIO *bio, const BIO_METHOD *method)

ssl/ssl_txt.c:47:9: Taking false branch
45.       int ret;
46.   
47.       if ((b = BIO_new(BIO_s_file())) == NULL) {
              ^
48.           SSLerr(SSL_F_SSL_SESSION_PRINT_FP, ERR_R_BUF_LIB);
49.           return (0);

ssl/ssl_txt.c:51:5: 
49.           return (0);
50.       }
51. >     BIO_set_fp(b, fp, BIO_NOCLOSE);
52.       ret = SSL_SESSION_print(b, x);
53.       BIO_free(b);

crypto/bio/bio_lib.c:343:1: start of procedure BIO_ctrl()
  341.   }
  342.   
  343. > long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)
  344.   {
  345.       long ret;

crypto/bio/bio_lib.c:348:9: Taking false branch
  346.       long (*cb) (BIO *, int, const char *, int, long, long);
  347.   
  348.       if (b == NULL)
                 ^
  349.           return (0);
  350.   

crypto/bio/bio_lib.c:351:10: Taking false branch
  349.           return (0);
  350.   
  351.       if ((b->method == NULL) || (b->method->ctrl == NULL)) {
                  ^
  352.           BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);
  353.           return (-2);

crypto/bio/bio_lib.c:351:33: Taking true branch
  349.           return (0);
  350.   
  351.       if ((b->method == NULL) || (b->method->ctrl == NULL)) {
                                         ^
  352.           BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);
  353.           return (-2);

crypto/bio/bio_lib.c:352:9: Skipping ERR_put_error(): empty list of specs
  350.   
  351.       if ((b->method == NULL) || (b->method->ctrl == NULL)) {
  352.           BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);
                 ^
  353.           return (-2);
  354.       }

crypto/bio/bio_lib.c:353:9: 
  351.       if ((b->method == NULL) || (b->method->ctrl == NULL)) {
  352.           BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);
  353. >         return (-2);
  354.       }
  355.   

crypto/bio/bio_lib.c:367:1: return from a call to BIO_ctrl
  365.           ret = cb(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, cmd, larg, ret);
  366.       return (ret);
  367. > }
  368.   
  369.   long BIO_callback_ctrl(BIO *b, int cmd,

ssl/ssl_txt.c:52:5: 
50.       }
51.       BIO_set_fp(b, fp, BIO_NOCLOSE);
52. >     ret = SSL_SESSION_print(b, x);
53.       BIO_free(b);
54.       return (ret);

ssl/ssl_txt.c:58:1: start of procedure SSL_SESSION_print()
  56.   #endif
  57.   
  58. > int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x)
  59.   {
  60.       unsigned int i;

ssl/ssl_txt.c:63:9: Taking false branch
  61.       const char *s;
  62.   
  63.       if (x == NULL)
                ^
  64.           goto err;
  65.       if (BIO_puts(bp, "SSL-Session:\n") <= 0)

ssl/ssl_txt.c:65:9: 
  63.       if (x == NULL)
  64.           goto err;
  65. >     if (BIO_puts(bp, "SSL-Session:\n") <= 0)
  66.           goto err;
  67.       s = ssl_protocol_to_string(x->ssl_version);

crypto/bio/bio_lib.c:256:1: start of procedure BIO_puts()
    254.   }
    255.   
    256. > int BIO_puts(BIO *b, const char *in)
    257.   {
    258.       int i;

crypto/bio/bio_lib.c:261:10: Taking false branch
    259.       long (*cb) (BIO *, int, const char *, int, long, long);
    260.   
    261.       if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
                    ^
    262.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
    263.           return (-2);

crypto/bio/bio_lib.c:261:25: Taking false branch
    259.       long (*cb) (BIO *, int, const char *, int, long, long);
    260.   
    261.       if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
                                   ^
    262.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
    263.           return (-2);

crypto/bio/bio_lib.c:261:48: Taking false branch
    259.       long (*cb) (BIO *, int, const char *, int, long, long);
    260.   
    261.       if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
                                                          ^
    262.           BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
    263.           return (-2);

crypto/bio/bio_lib.c:266:5: 
    264.       }
    265.   
    266. >     cb = b->callback;
    267.   
    268.       if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_PUTS, in, 0, 0L, 1L)) <= 0))

crypto/bio/bio_lib.c:268:10: Taking true branch
    266.       cb = b->callback;
    267.   
    268.       if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_PUTS, in, 0, 0L, 1L)) <= 0))
                    ^
    269.           return (i);
    270.   

crypto/bio/bio_lib.c:268:26: Taking true branch
    266.       cb = b->callback;
    267.   
    268.       if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_PUTS, in, 0, 0L, 1L)) <= 0))
                                    ^
    269.           return (i);
    270.   

crypto/bio/bio_lib.c:269:9: 
    267.   
    268.       if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_PUTS, in, 0, 0L, 1L)) <= 0))
    269. >         return (i);
    270.   
    271.       if (!b->init) {

crypto/bio/bio_lib.c:284:1: return from a call to BIO_puts
    282.           i = (int)cb(b, BIO_CB_PUTS | BIO_CB_RETURN, in, 0, 0L, (long)i);
    283.       return (i);
    284. > }
    285.   
    286.   int BIO_gets(BIO *b, char *in, int inl)

ssl/ssl_txt.c:65:9: Taking true branch
  63.       if (x == NULL)
  64.           goto err;
  65.       if (BIO_puts(bp, "SSL-Session:\n") <= 0)
                ^
  66.           goto err;
  67.       s = ssl_protocol_to_string(x->ssl_version);

ssl/ssl_txt.c:175:2: 
  173.   
  174.       return (1);
  175. >  err:
  176.       return (0);
  177.   }

ssl/ssl_txt.c:176:5: 
  174.       return (1);
  175.    err:
  176. >     return (0);
  177.   }
  178.   

ssl/ssl_txt.c:177:1: return from a call to SSL_SESSION_print
  175.    err:
  176.       return (0);
  177. > }
  178.   
  179.   /*

ssl/ssl_txt.c:53:5: Skipping BIO_free(): empty list of specs
51.       BIO_set_fp(b, fp, BIO_NOCLOSE);
52.       ret = SSL_SESSION_print(b, x);
53.       BIO_free(b);
          ^
54.       return (ret);
55.   }

int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *x)
{
    BIO *b;
    int ret;
    if ((b = BIO_new(BIO_s_file())) == NULL) {
        SSLerr(SSL_F_SSL_SESSION_PRINT_FP, ERR_R_BUF_LIB);
        return (0);
    }
    BIO_set_fp(b, fp, BIO_NOCLOSE);
    ret = SSL_SESSION_print(b, x);
    BIO_free(b);
    return (ret);
}
['int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *x)\n{\n    BIO *b;\n    int ret;\n    if ((b = BIO_new(BIO_s_file())) == NULL) {\n        SSLerr(SSL_F_SSL_SESSION_PRINT_FP, ERR_R_BUF_LIB);\n        return (0);\n    }\n    BIO_set_fp(b, fp, BIO_NOCLOSE);\n    ret = SSL_SESSION_print(b, x);\n    BIO_free(b);\n    return (ret);\n}', 'const BIO_METHOD *BIO_s_file(void)\n{\n    return (&methods_filep);\n}', 'BIO *BIO_new(const BIO_METHOD *method)\n{\n    BIO *ret = OPENSSL_malloc(sizeof(*ret));\n    if (ret == NULL) {\n        BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    if (!BIO_set(ret, method)) {\n        OPENSSL_free(ret);\n        ret = NULL;\n    }\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}', 'long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)\n{\n    long ret;\n    long (*cb) (BIO *, int, const char *, int, long, long);\n    if (b == NULL)\n        return (0);\n    if ((b->method == NULL) || (b->method->ctrl == NULL)) {\n        BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);\n        return (-2);\n    }\n    cb = b->callback;\n    if ((cb != NULL) &&\n        ((ret = cb(b, BIO_CB_CTRL, parg, cmd, larg, 1L)) <= 0))\n        return (ret);\n    ret = b->method->ctrl(b, cmd, larg, parg);\n    if (cb != NULL)\n        ret = cb(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, cmd, larg, ret);\n    return (ret);\n}', 'int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x)\n{\n    unsigned int i;\n    const char *s;\n    if (x == NULL)\n        goto err;\n    if (BIO_puts(bp, "SSL-Session:\\n") <= 0)\n        goto err;\n    s = ssl_protocol_to_string(x->ssl_version);\n    if (BIO_printf(bp, "    Protocol  : %s\\n", s) <= 0)\n        goto err;\n    if (x->cipher == NULL) {\n        if (((x->cipher_id) & 0xff000000) == 0x02000000) {\n            if (BIO_printf\n                (bp, "    Cipher    : %06lX\\n", x->cipher_id & 0xffffff) <= 0)\n                goto err;\n        } else {\n            if (BIO_printf\n                (bp, "    Cipher    : %04lX\\n", x->cipher_id & 0xffff) <= 0)\n                goto err;\n        }\n    } else {\n        if (BIO_printf\n            (bp, "    Cipher    : %s\\n",\n             ((x->cipher == NULL) ? "unknown" : x->cipher->name)) <= 0)\n            goto err;\n    }\n    if (BIO_puts(bp, "    Session-ID: ") <= 0)\n        goto err;\n    for (i = 0; i < x->session_id_length; i++) {\n        if (BIO_printf(bp, "%02X", x->session_id[i]) <= 0)\n            goto err;\n    }\n    if (BIO_puts(bp, "\\n    Session-ID-ctx: ") <= 0)\n        goto err;\n    for (i = 0; i < x->sid_ctx_length; i++) {\n        if (BIO_printf(bp, "%02X", x->sid_ctx[i]) <= 0)\n            goto err;\n    }\n    if (BIO_puts(bp, "\\n    Master-Key: ") <= 0)\n        goto err;\n    for (i = 0; i < (unsigned int)x->master_key_length; i++) {\n        if (BIO_printf(bp, "%02X", x->master_key[i]) <= 0)\n            goto err;\n    }\n#ifndef OPENSSL_NO_PSK\n    if (BIO_puts(bp, "\\n    PSK identity: ") <= 0)\n        goto err;\n    if (BIO_printf(bp, "%s", x->psk_identity ? x->psk_identity : "None") <= 0)\n        goto err;\n    if (BIO_puts(bp, "\\n    PSK identity hint: ") <= 0)\n        goto err;\n    if (BIO_printf\n        (bp, "%s", x->psk_identity_hint ? x->psk_identity_hint : "None") <= 0)\n        goto err;\n#endif\n#ifndef OPENSSL_NO_SRP\n    if (BIO_puts(bp, "\\n    SRP username: ") <= 0)\n        goto err;\n    if (BIO_printf(bp, "%s", x->srp_username ? x->srp_username : "None") <= 0)\n        goto err;\n#endif\n    if (x->tlsext_tick_lifetime_hint) {\n        if (BIO_printf(bp,\n                       "\\n    TLS session ticket lifetime hint: %ld (seconds)",\n                       x->tlsext_tick_lifetime_hint) <= 0)\n            goto err;\n    }\n    if (x->tlsext_tick) {\n        if (BIO_puts(bp, "\\n    TLS session ticket:\\n") <= 0)\n            goto err;\n        if (BIO_dump_indent(bp, (char *)x->tlsext_tick, x->tlsext_ticklen, 4)\n            <= 0)\n            goto err;\n    }\n#ifndef OPENSSL_NO_COMP\n    if (x->compress_meth != 0) {\n        SSL_COMP *comp = NULL;\n        if (!ssl_cipher_get_evp(x, NULL, NULL, NULL, NULL, &comp, 0))\n            goto err;\n        if (comp == NULL) {\n            if (BIO_printf(bp, "\\n    Compression: %d", x->compress_meth) <=\n                0)\n                goto err;\n        } else {\n            if (BIO_printf(bp, "\\n    Compression: %d (%s)", comp->id,\n                 comp->name) <= 0)\n                goto err;\n        }\n    }\n#endif\n    if (x->time != 0L) {\n        if (BIO_printf(bp, "\\n    Start Time: %ld", x->time) <= 0)\n            goto err;\n    }\n    if (x->timeout != 0L) {\n        if (BIO_printf(bp, "\\n    Timeout   : %ld (sec)", x->timeout) <= 0)\n            goto err;\n    }\n    if (BIO_puts(bp, "\\n") <= 0)\n        goto err;\n    if (BIO_puts(bp, "    Verify return code: ") <= 0)\n        goto err;\n    if (BIO_printf(bp, "%ld (%s)\\n", x->verify_result,\n                   X509_verify_cert_error_string(x->verify_result)) <= 0)\n        goto err;\n    if (BIO_printf(bp, "    Extended master secret: %s\\n",\n                   x->flags & SSL_SESS_FLAG_EXTMS ? "yes" : "no") <= 0)\n        goto err;\n    return (1);\n err:\n    return (0);\n}', 'int BIO_puts(BIO *b, const char *in)\n{\n    int i;\n    long (*cb) (BIO *, int, const char *, int, long, long);\n    if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {\n        BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);\n        return (-2);\n    }\n    cb = b->callback;\n    if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_PUTS, in, 0, 0L, 1L)) <= 0))\n        return (i);\n    if (!b->init) {\n        BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);\n        return (-2);\n    }\n    i = b->method->bputs(b, in);\n    if (i > 0)\n        b->num_write += (uint64_t)i;\n    if (cb != NULL)\n        i = (int)cb(b, BIO_CB_PUTS | BIO_CB_RETURN, in, 0, 0L, (long)i);\n    return (i);\n}']