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


ssl/ssl_rsa.c:37:1: start of procedure SSL_use_certificate_file()
35.   
36.   #ifndef OPENSSL_NO_STDIO
37. > int SSL_use_certificate_file(SSL *ssl, const char *file, int type)
38.   {
39.       int j;

ssl/ssl_rsa.c:41:5: 
39.       int j;
40.       BIO *in;
41. >     int ret = 0;
42.       X509 *x = NULL;
43.   

ssl/ssl_rsa.c:42:5: 
40.       BIO *in;
41.       int ret = 0;
42. >     X509 *x = NULL;
43.   
44.       in = BIO_new(BIO_s_file());

ssl/ssl_rsa.c:44:5: 
42.       X509 *x = NULL;
43.   
44. >     in = BIO_new(BIO_s_file());
45.       if (in == NULL) {
46.           SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_BUF_LIB);

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_rsa.c:45:9: Taking false branch
43.   
44.       in = BIO_new(BIO_s_file());
45.       if (in == NULL) {
              ^
46.           SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_BUF_LIB);
47.           goto end;

ssl/ssl_rsa.c:50:9: 
48.       }
49.   
50. >     if (BIO_read_filename(in, file) <= 0) {
51.           SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_SYS_LIB);
52.           goto end;

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 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:356:5: 
  354.       }
  355.   
  356. >     cb = b->callback;
  357.   
  358.       if ((cb != NULL) &&

crypto/bio/bio_lib.c:358:10: Taking true branch
  356.       cb = b->callback;
  357.   
  358.       if ((cb != NULL) &&
                  ^
  359.           ((ret = cb(b, BIO_CB_CTRL, parg, cmd, larg, 1L)) <= 0))
  360.           return (ret);

crypto/bio/bio_lib.c:359:10: Taking false branch
  357.   
  358.       if ((cb != NULL) &&
  359.           ((ret = cb(b, BIO_CB_CTRL, parg, cmd, larg, 1L)) <= 0))
                  ^
  360.           return (ret);
  361.   

crypto/bio/bio_lib.c:362:5: Skipping __function_pointer__(): unresolved function pointer
  360.           return (ret);
  361.   
  362.       ret = b->method->ctrl(b, cmd, larg, parg);
             ^
  363.   
  364.       if (cb != NULL)

crypto/bio/bio_lib.c:364:9: Taking true branch
  362.       ret = b->method->ctrl(b, cmd, larg, parg);
  363.   
  364.       if (cb != NULL)
                 ^
  365.           ret = cb(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, cmd, larg, ret);
  366.       return (ret);

crypto/bio/bio_lib.c:365:9: Skipping __function_pointer__(): unresolved function pointer
  363.   
  364.       if (cb != NULL)
  365.           ret = cb(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, cmd, larg, ret);
                 ^
  366.       return (ret);
  367.   }

crypto/bio/bio_lib.c:366:5: 
  364.       if (cb != NULL)
  365.           ret = cb(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, cmd, larg, ret);
  366. >     return (ret);
  367.   }
  368.   

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_rsa.c:50:9: Taking true branch
48.       }
49.   
50.       if (BIO_read_filename(in, file) <= 0) {
              ^
51.           SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_SYS_LIB);
52.           goto end;

ssl/ssl_rsa.c:51:9: Skipping ERR_put_error(): empty list of specs
49.   
50.       if (BIO_read_filename(in, file) <= 0) {
51.           SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_SYS_LIB);
              ^
52.           goto end;
53.       }

ssl/ssl_rsa.c:72:2: 
70.   
71.       ret = SSL_use_certificate(ssl, x);
72. >  end:
73.       X509_free(x);
74.       BIO_free(in);

ssl/ssl_rsa.c:73:5: 
71.       ret = SSL_use_certificate(ssl, x);
72.    end:
73. >     X509_free(x);
74.       BIO_free(in);
75.       return (ret);

crypto/x509/x_x509.c:85:1: start of procedure X509_free()
  83.   } ASN1_SEQUENCE_END_ref(X509, X509)
  84.   
  85. > IMPLEMENT_ASN1_FUNCTIONS(X509)
  86.   
  87.   IMPLEMENT_ASN1_DUP_FUNCTION(X509)

crypto/asn1/tasn_fre.c:21:1: start of procedure ASN1_item_free()
    19.   /* Free up an ASN1 structure */
    20.   
    21. > void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it)
    22.   {
    23.       asn1_item_embed_free(&val, it, 0);

crypto/asn1/tasn_fre.c:23:5: Skipping asn1_item_embed_free(): empty list of specs
    21.   void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it)
    22.   {
    23.       asn1_item_embed_free(&val, it, 0);
              ^
    24.   }
    25.   

crypto/asn1/tasn_fre.c:24:1: return from a call to ASN1_item_free
    22.   {
    23.       asn1_item_embed_free(&val, it, 0);
    24. > }
    25.   
    26.   void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it)

crypto/x509/x_x509.c:85:1: return from a call to X509_free
  83.   } ASN1_SEQUENCE_END_ref(X509, X509)
  84.   
  85. > IMPLEMENT_ASN1_FUNCTIONS(X509)
  86.   
  87.   IMPLEMENT_ASN1_DUP_FUNCTION(X509)

ssl/ssl_rsa.c:74:5: Skipping BIO_free(): empty list of specs
72.    end:
73.       X509_free(x);
74.       BIO_free(in);
          ^
75.       return (ret);
76.   }

int SSL_use_certificate_file(SSL *ssl, const char *file, int type)
{
    int j;
    BIO *in;
    int ret = 0;
    X509 *x = NULL;
    in = BIO_new(BIO_s_file());
    if (in == NULL) {
        SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_BUF_LIB);
        goto end;
    }
    if (BIO_read_filename(in, file) <= 0) {
        SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_SYS_LIB);
        goto end;
    }
    if (type == SSL_FILETYPE_ASN1) {
        j = ERR_R_ASN1_LIB;
        x = d2i_X509_bio(in, NULL);
    } else if (type == SSL_FILETYPE_PEM) {
        j = ERR_R_PEM_LIB;
        x = PEM_read_bio_X509(in, NULL, ssl->ctx->default_passwd_callback,
                              ssl->ctx->default_passwd_callback_userdata);
    } else {
        SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, SSL_R_BAD_SSL_FILETYPE);
        goto end;
    }
    if (x == NULL) {
        SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, j);
        goto end;
    }
    ret = SSL_use_certificate(ssl, x);
 end:
    X509_free(x);
    BIO_free(in);
    return (ret);
}
['int SSL_use_certificate_file(SSL *ssl, const char *file, int type)\n{\n    int j;\n    BIO *in;\n    int ret = 0;\n    X509 *x = NULL;\n    in = BIO_new(BIO_s_file());\n    if (in == NULL) {\n        SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_BUF_LIB);\n        goto end;\n    }\n    if (BIO_read_filename(in, file) <= 0) {\n        SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_SYS_LIB);\n        goto end;\n    }\n    if (type == SSL_FILETYPE_ASN1) {\n        j = ERR_R_ASN1_LIB;\n        x = d2i_X509_bio(in, NULL);\n    } else if (type == SSL_FILETYPE_PEM) {\n        j = ERR_R_PEM_LIB;\n        x = PEM_read_bio_X509(in, NULL, ssl->ctx->default_passwd_callback,\n                              ssl->ctx->default_passwd_callback_userdata);\n    } else {\n        SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, SSL_R_BAD_SSL_FILETYPE);\n        goto end;\n    }\n    if (x == NULL) {\n        SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, j);\n        goto end;\n    }\n    ret = SSL_use_certificate(ssl, x);\n end:\n    X509_free(x);\n    BIO_free(in);\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}', 'IMPLEMENT_ASN1_FUNCTIONS(X509)', 'void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it)\n{\n    asn1_item_embed_free(&val, it, 0);\n}']