apps/ts.c:976: error: MEMORY_LEAK
  memory dynamically allocated by call to `TS_VERIFY_CTX_new()` at line 933, column 20 is not reachable after line 976, column 9.
Showing all 74 steps of the trace


apps/ts.c:920:1: start of procedure create_verify_ctx()
918.   }
919.   
920. > static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest,
921.                                           char *queryfile,
922.                                           char *CApath, char *CAfile,

apps/ts.c:926:5: 
924.                                           X509_VERIFY_PARAM *vpm)
925.   {
926. >     TS_VERIFY_CTX *ctx = NULL;
927.       BIO *input = NULL;
928.       TS_REQ *request = NULL;

apps/ts.c:927:5: 
925.   {
926.       TS_VERIFY_CTX *ctx = NULL;
927. >     BIO *input = NULL;
928.       TS_REQ *request = NULL;
929.       int ret = 0;

apps/ts.c:928:5: 
926.       TS_VERIFY_CTX *ctx = NULL;
927.       BIO *input = NULL;
928. >     TS_REQ *request = NULL;
929.       int ret = 0;
930.       int f = 0;

apps/ts.c:929:5: 
927.       BIO *input = NULL;
928.       TS_REQ *request = NULL;
929. >     int ret = 0;
930.       int f = 0;
931.   

apps/ts.c:930:5: 
928.       TS_REQ *request = NULL;
929.       int ret = 0;
930. >     int f = 0;
931.   
932.       if (data != NULL || digest != NULL) {

apps/ts.c:932:9: Taking true branch
930.       int f = 0;
931.   
932.       if (data != NULL || digest != NULL) {
               ^
933.           if ((ctx = TS_VERIFY_CTX_new()) == NULL)
934.               goto err;

apps/ts.c:933:13: 
931.   
932.       if (data != NULL || digest != NULL) {
933. >         if ((ctx = TS_VERIFY_CTX_new()) == NULL)
934.               goto err;
935.           f = TS_VFY_VERSION | TS_VFY_SIGNER;

crypto/ts/ts_verify_ctx.c:64:1: start of procedure TS_VERIFY_CTX_new()
  62.   #include "ts_lcl.h"
  63.   
  64. > TS_VERIFY_CTX *TS_VERIFY_CTX_new(void)
  65.   {
  66.       TS_VERIFY_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));

crypto/ts/ts_verify_ctx.c:66:5: 
  64.   TS_VERIFY_CTX *TS_VERIFY_CTX_new(void)
  65.   {
  66. >     TS_VERIFY_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  67.   
  68.       if (ctx == NULL)

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/ts/ts_verify_ctx.c:68:9: Taking false branch
  66.       TS_VERIFY_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
  67.   
  68.       if (ctx == NULL)
                ^
  69.           TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE);
  70.       return ctx;

crypto/ts/ts_verify_ctx.c:70:5: 
  68.       if (ctx == NULL)
  69.           TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE);
  70. >     return ctx;
  71.   }
  72.   

crypto/ts/ts_verify_ctx.c:71:1: return from a call to TS_VERIFY_CTX_new
  69.           TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE);
  70.       return ctx;
  71. > }
  72.   
  73.   void TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx)

apps/ts.c:933:13: Taking false branch
931.   
932.       if (data != NULL || digest != NULL) {
933.           if ((ctx = TS_VERIFY_CTX_new()) == NULL)
                   ^
934.               goto err;
935.           f = TS_VFY_VERSION | TS_VFY_SIGNER;

apps/ts.c:935:9: 
933.           if ((ctx = TS_VERIFY_CTX_new()) == NULL)
934.               goto err;
935. >         f = TS_VFY_VERSION | TS_VFY_SIGNER;
936.           if (data != NULL) {
937.               f |= TS_VFY_DATA;

apps/ts.c:936:13: Taking true branch
934.               goto err;
935.           f = TS_VFY_VERSION | TS_VFY_SIGNER;
936.           if (data != NULL) {
                   ^
937.               f |= TS_VFY_DATA;
938.               if (TS_VERIFY_CTX_set_data(ctx, BIO_new_file(data, "rb")) == NULL)

apps/ts.c:937:13: 
935.           f = TS_VFY_VERSION | TS_VFY_SIGNER;
936.           if (data != NULL) {
937. >             f |= TS_VFY_DATA;
938.               if (TS_VERIFY_CTX_set_data(ctx, BIO_new_file(data, "rb")) == NULL)
939.                   goto err;

apps/ts.c:938:17: 
936.           if (data != NULL) {
937.               f |= TS_VFY_DATA;
938. >             if (TS_VERIFY_CTX_set_data(ctx, BIO_new_file(data, "rb")) == NULL)
939.                   goto err;
940.           } else if (digest != NULL) {

crypto/bio/bss_file.c:163:1: start of procedure BIO_new_file()
  161.   }
  162.   
  163. > BIO *BIO_new_file(const char *filename, const char *mode)
  164.   {
  165.       BIO  *ret;

crypto/bio/bss_file.c:166:5: 
  164.   {
  165.       BIO  *ret;
  166. >     FILE *file = file_fopen(filename, mode);
  167.       int fp_flags = BIO_CLOSE;
  168.   

crypto/bio/bss_file.c:112:1: start of procedure file_fopen()
    110.   };
    111.   
    112. > static FILE *file_fopen(const char *filename, const char *mode)
    113.   {
    114.       FILE *file = NULL;

crypto/bio/bss_file.c:114:5: 
    112.   static FILE *file_fopen(const char *filename, const char *mode)
    113.   {
    114. >     FILE *file = NULL;
    115.   
    116.   #  if defined(_WIN32) && defined(CP_UTF8)

crypto/bio/bss_file.c:158:5: 
    156.       }
    157.   #  else
    158. >     file = fopen(filename, mode);
    159.   #  endif
    160.       return (file);

crypto/bio/bss_file.c:160:5: 
    158.       file = fopen(filename, mode);
    159.   #  endif
    160. >     return (file);
    161.   }
    162.   

crypto/bio/bss_file.c:161:1: return from a call to file_fopen
    159.   #  endif
    160.       return (file);
    161. > }
    162.   
    163.   BIO *BIO_new_file(const char *filename, const char *mode)

crypto/bio/bss_file.c:167:5: 
  165.       BIO  *ret;
  166.       FILE *file = file_fopen(filename, mode);
  167. >     int fp_flags = BIO_CLOSE;
  168.   
  169.       if (strchr(mode, 'b') == NULL)

crypto/bio/bss_file.c:169:9: Taking false branch
  167.       int fp_flags = BIO_CLOSE;
  168.   
  169.       if (strchr(mode, 'b') == NULL)
                 ^
  170.           fp_flags |= BIO_FP_TEXT;
  171.   

crypto/bio/bss_file.c:172:9: Taking true branch
  170.           fp_flags |= BIO_FP_TEXT;
  171.   
  172.       if (file == NULL) {
                 ^
  173.           SYSerr(SYS_F_FOPEN, get_last_sys_error());
  174.           ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");

crypto/bio/bss_file.c:173:9: 
  171.   
  172.       if (file == NULL) {
  173. >         SYSerr(SYS_F_FOPEN, get_last_sys_error());
  174.           ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");
  175.           if (errno == ENOENT)

crypto/bio/bss_file.c:174:9: 
  172.       if (file == NULL) {
  173.           SYSerr(SYS_F_FOPEN, get_last_sys_error());
  174. >         ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");
  175.           if (errno == ENOENT)
  176.               BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);

crypto/err/err.c:819:1: start of procedure ERR_add_error_data()
    817.   }
    818.   
    819. > void ERR_add_error_data(int num, ...)
    820.   {
    821.       va_list args;

crypto/err/err.c:822:5: 
    820.   {
    821.       va_list args;
    822. >     va_start(args, num);
    823.       ERR_add_error_vdata(num, args);
    824.       va_end(args);

crypto/err/err.c:823:5: Skipping ERR_add_error_vdata(): empty list of specs
    821.       va_list args;
    822.       va_start(args, num);
    823.       ERR_add_error_vdata(num, args);
               ^
    824.       va_end(args);
    825.   }

crypto/err/err.c:824:5: 
    822.       va_start(args, num);
    823.       ERR_add_error_vdata(num, args);
    824. >     va_end(args);
    825.   }
    826.   

crypto/err/err.c:825:1: return from a call to ERR_add_error_data
    823.       ERR_add_error_vdata(num, args);
    824.       va_end(args);
    825. > }
    826.   
    827.   void ERR_add_error_vdata(int num, va_list args)

crypto/bio/bss_file.c:175:13: Taking true branch
  173.           SYSerr(SYS_F_FOPEN, get_last_sys_error());
  174.           ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");
  175.           if (errno == ENOENT)
                     ^
  176.               BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);
  177.           else

crypto/bio/bss_file.c:176:13: Skipping ERR_put_error(): empty list of specs
  174.           ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");
  175.           if (errno == ENOENT)
  176.               BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);
                     ^
  177.           else
  178.               BIOerr(BIO_F_BIO_NEW_FILE, ERR_R_SYS_LIB);

crypto/bio/bss_file.c:179:9: 
  177.           else
  178.               BIOerr(BIO_F_BIO_NEW_FILE, ERR_R_SYS_LIB);
  179. >         return (NULL);
  180.       }
  181.       if ((ret = BIO_new(BIO_s_file())) == NULL) {

crypto/bio/bss_file.c:190:1: return from a call to BIO_new_file
  188.       BIO_set_fp(ret, file, fp_flags);
  189.       return (ret);
  190. > }
  191.   
  192.   BIO *BIO_new_fp(FILE *stream, int close_flag)

crypto/ts/ts_verify_ctx.c:100:1: start of procedure TS_VERIFY_CTX_set_data()
  98.   }
  99.   
  100. > BIO *TS_VERIFY_CTX_set_data(TS_VERIFY_CTX *ctx, BIO *b)
  101.   {
  102.       ctx->data = b;

crypto/ts/ts_verify_ctx.c:102:5: 
  100.   BIO *TS_VERIFY_CTX_set_data(TS_VERIFY_CTX *ctx, BIO *b)
  101.   {
  102. >     ctx->data = b;
  103.       return ctx->data;
  104.   }

crypto/ts/ts_verify_ctx.c:103:5: 
  101.   {
  102.       ctx->data = b;
  103. >     return ctx->data;
  104.   }
  105.   

crypto/ts/ts_verify_ctx.c:104:1: return from a call to TS_VERIFY_CTX_set_data
  102.       ctx->data = b;
  103.       return ctx->data;
  104. > }
  105.   
  106.   X509_STORE *TS_VERIFY_CTX_set_store(TS_VERIFY_CTX *ctx, X509_STORE *s)

apps/ts.c:938:17: Taking true branch
936.           if (data != NULL) {
937.               f |= TS_VFY_DATA;
938.               if (TS_VERIFY_CTX_set_data(ctx, BIO_new_file(data, "rb")) == NULL)
                       ^
939.                   goto err;
940.           } else if (digest != NULL) {

apps/ts.c:974:2: 
972.       ret = 1;
973.   
974. >  err:
975.       if (!ret) {
976.           TS_VERIFY_CTX_free(ctx);

apps/ts.c:975:10: Taking true branch
973.   
974.    err:
975.       if (!ret) {
                ^
976.           TS_VERIFY_CTX_free(ctx);
977.           ctx = NULL;

apps/ts.c:976:9: 
974.    err:
975.       if (!ret) {
976. >         TS_VERIFY_CTX_free(ctx);
977.           ctx = NULL;
978.       }

crypto/ts/ts_verify_ctx.c:79:1: start of procedure TS_VERIFY_CTX_free()
  77.   }
  78.   
  79. > void TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx)
  80.   {
  81.       if (!ctx)

crypto/ts/ts_verify_ctx.c:81:10: Taking false branch
  79.   void TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx)
  80.   {
  81.       if (!ctx)
                 ^
  82.           return;
  83.   

crypto/ts/ts_verify_ctx.c:84:5: Skipping TS_VERIFY_CTX_cleanup(): empty list of specs
  82.           return;
  83.   
  84.       TS_VERIFY_CTX_cleanup(ctx);
            ^
  85.       OPENSSL_free(ctx);
  86.   }

crypto/ts/ts_verify_ctx.c:85:5: 
  83.   
  84.       TS_VERIFY_CTX_cleanup(ctx);
  85. >     OPENSSL_free(ctx);
  86.   }
  87.   

crypto/mem.c:210:1: start of procedure CRYPTO_free()
    208.   }
    209.   
    210. > void CRYPTO_free(void *str, const char *file, int line)
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:212:9: Taking true branch
    210.   void CRYPTO_free(void *str, const char *file, int line)
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                   ^
    213.           free_impl(str, file, line);
    214.           return;

crypto/mem.c:212:30: Taking true branch
    210.   void CRYPTO_free(void *str, const char *file, int line)
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                        ^
    213.           free_impl(str, file, line);
    214.           return;

crypto/mem.c:213:9: Skipping __function_pointer__(): unresolved function pointer
    211.   {
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    213.           free_impl(str, file, line);
                   ^
    214.           return;
    215.       }

crypto/mem.c:214:9: 
    212.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
    213.           free_impl(str, file, line);
    214. >         return;
    215.       }
    216.   

crypto/mem.c:228:1: return from a call to CRYPTO_free
    226.       free(str);
    227.   #endif
    228. > }
    229.   
    230.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

crypto/ts/ts_verify_ctx.c:86:1: return from a call to TS_VERIFY_CTX_free
  84.       TS_VERIFY_CTX_cleanup(ctx);
  85.       OPENSSL_free(ctx);
  86. > }
  87.   
  88.   int TS_VERIFY_CTX_add_flags(TS_VERIFY_CTX *ctx, int f)

static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest,
                                        char *queryfile,
                                        char *CApath, char *CAfile,
                                        char *untrusted,
                                        X509_VERIFY_PARAM *vpm)
{
    TS_VERIFY_CTX *ctx = NULL;
    BIO *input = NULL;
    TS_REQ *request = NULL;
    int ret = 0;
    int f = 0;
    if (data != NULL || digest != NULL) {
        if ((ctx = TS_VERIFY_CTX_new()) == NULL)
            goto err;
        f = TS_VFY_VERSION | TS_VFY_SIGNER;
        if (data != NULL) {
            f |= TS_VFY_DATA;
            if (TS_VERIFY_CTX_set_data(ctx, BIO_new_file(data, "rb")) == NULL)
                goto err;
        } else if (digest != NULL) {
            long imprint_len;
            unsigned char *hexstr = OPENSSL_hexstr2buf(digest, &imprint_len);
            f |= TS_VFY_IMPRINT;
            if (TS_VERIFY_CTX_set_imprint(ctx, hexstr, imprint_len) == NULL) {
                BIO_printf(bio_err, "invalid digest string\n");
                goto err;
            }
        }
    } else if (queryfile != NULL) {
        if ((input = BIO_new_file(queryfile, "rb")) == NULL)
            goto err;
        if ((request = d2i_TS_REQ_bio(input, NULL)) == NULL)
            goto err;
        if ((ctx = TS_REQ_to_TS_VERIFY_CTX(request, NULL)) == NULL)
            goto err;
    } else
        return NULL;
    TS_VERIFY_CTX_add_flags(ctx, f | TS_VFY_SIGNATURE);
    if (TS_VERIFY_CTX_set_store(ctx, create_cert_store(CApath, CAfile, vpm))
            == NULL)
        goto err;
    if (untrusted
        && TS_VERIFY_CTS_set_certs(ctx, TS_CONF_load_certs(untrusted)) == NULL)
        goto err;
    ret = 1;
 err:
    if (!ret) {
        TS_VERIFY_CTX_free(ctx);
        ctx = NULL;
    }
    BIO_free_all(input);
    TS_REQ_free(request);
    return ctx;
}
['static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest,\n                                        char *queryfile,\n                                        char *CApath, char *CAfile,\n                                        char *untrusted,\n                                        X509_VERIFY_PARAM *vpm)\n{\n    TS_VERIFY_CTX *ctx = NULL;\n    BIO *input = NULL;\n    TS_REQ *request = NULL;\n    int ret = 0;\n    int f = 0;\n    if (data != NULL || digest != NULL) {\n        if ((ctx = TS_VERIFY_CTX_new()) == NULL)\n            goto err;\n        f = TS_VFY_VERSION | TS_VFY_SIGNER;\n        if (data != NULL) {\n            f |= TS_VFY_DATA;\n            if (TS_VERIFY_CTX_set_data(ctx, BIO_new_file(data, "rb")) == NULL)\n                goto err;\n        } else if (digest != NULL) {\n            long imprint_len;\n            unsigned char *hexstr = OPENSSL_hexstr2buf(digest, &imprint_len);\n            f |= TS_VFY_IMPRINT;\n            if (TS_VERIFY_CTX_set_imprint(ctx, hexstr, imprint_len) == NULL) {\n                BIO_printf(bio_err, "invalid digest string\\n");\n                goto err;\n            }\n        }\n    } else if (queryfile != NULL) {\n        if ((input = BIO_new_file(queryfile, "rb")) == NULL)\n            goto err;\n        if ((request = d2i_TS_REQ_bio(input, NULL)) == NULL)\n            goto err;\n        if ((ctx = TS_REQ_to_TS_VERIFY_CTX(request, NULL)) == NULL)\n            goto err;\n    } else\n        return NULL;\n    TS_VERIFY_CTX_add_flags(ctx, f | TS_VFY_SIGNATURE);\n    if (TS_VERIFY_CTX_set_store(ctx, create_cert_store(CApath, CAfile, vpm))\n            == NULL)\n        goto err;\n    if (untrusted\n        && TS_VERIFY_CTS_set_certs(ctx, TS_CONF_load_certs(untrusted)) == NULL)\n        goto err;\n    ret = 1;\n err:\n    if (!ret) {\n        TS_VERIFY_CTX_free(ctx);\n        ctx = NULL;\n    }\n    BIO_free_all(input);\n    TS_REQ_free(request);\n    return ctx;\n}', 'TS_VERIFY_CTX *TS_VERIFY_CTX_new(void)\n{\n    TS_VERIFY_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));\n    if (ctx == NULL)\n        TSerr(TS_F_TS_VERIFY_CTX_NEW, ERR_R_MALLOC_FAILURE);\n    return ctx;\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}', 'BIO *BIO_new_file(const char *filename, const char *mode)\n{\n    BIO  *ret;\n    FILE *file = file_fopen(filename, mode);\n    int fp_flags = BIO_CLOSE;\n    if (strchr(mode, \'b\') == NULL)\n        fp_flags |= BIO_FP_TEXT;\n    if (file == NULL) {\n        SYSerr(SYS_F_FOPEN, get_last_sys_error());\n        ERR_add_error_data(5, "fopen(\'", filename, "\',\'", mode, "\')");\n        if (errno == ENOENT)\n            BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);\n        else\n            BIOerr(BIO_F_BIO_NEW_FILE, ERR_R_SYS_LIB);\n        return (NULL);\n    }\n    if ((ret = BIO_new(BIO_s_file())) == NULL) {\n        fclose(file);\n        return (NULL);\n    }\n    BIO_clear_flags(ret, BIO_FLAGS_UPLINK);\n    BIO_set_fp(ret, file, fp_flags);\n    return (ret);\n}', 'static FILE *file_fopen(const char *filename, const char *mode)\n{\n    FILE *file = NULL;\n#  if defined(_WIN32) && defined(CP_UTF8)\n    int sz, len_0 = (int)strlen(filename) + 1;\n    DWORD flags;\n    if ((sz = MultiByteToWideChar(CP_UTF8, (flags = MB_ERR_INVALID_CHARS),\n                                  filename, len_0, NULL, 0)) > 0 ||\n        (GetLastError() == ERROR_INVALID_FLAGS &&\n         (sz = MultiByteToWideChar(CP_UTF8, (flags = 0),\n                                   filename, len_0, NULL, 0)) > 0)\n        ) {\n        WCHAR wmode[8];\n        WCHAR *wfilename = _alloca(sz * sizeof(WCHAR));\n        if (MultiByteToWideChar(CP_UTF8, flags,\n                                filename, len_0, wfilename, sz) &&\n            MultiByteToWideChar(CP_UTF8, 0, mode, strlen(mode) + 1,\n                                wmode, OSSL_NELEM(wmode)) &&\n            (file = _wfopen(wfilename, wmode)) == NULL &&\n            (errno == ENOENT || errno == EBADF)\n            ) {\n            file = fopen(filename, mode);\n        }\n    } else if (GetLastError() == ERROR_NO_UNICODE_TRANSLATION) {\n        file = fopen(filename, mode);\n    }\n#  else\n    file = fopen(filename, mode);\n#  endif\n    return (file);\n}', 'void ERR_add_error_data(int num, ...)\n{\n    va_list args;\n    va_start(args, num);\n    ERR_add_error_vdata(num, args);\n    va_end(args);\n}', 'BIO *TS_VERIFY_CTX_set_data(TS_VERIFY_CTX *ctx, BIO *b)\n{\n    ctx->data = b;\n    return ctx->data;\n}', 'void TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx)\n{\n    if (!ctx)\n        return;\n    TS_VERIFY_CTX_cleanup(ctx);\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']