apps/apps.c:2834: error: RESOURCE_LEAK
  resource of type `_IO_FILE` acquired by call to `fdopen()` at line 2826, column 10 is not released after line 2834, column 16.
Showing all 33 steps of the trace


apps/apps.c:2798:1: start of procedure bio_open_owner()
2796.    * Open a file for writing, owner-read-only.
2797.    */
2798. > BIO *bio_open_owner(const char *filename, int format, int private)
2799.   {
2800.       FILE *fp = NULL;

apps/apps.c:2800:5: 
2798.   BIO *bio_open_owner(const char *filename, int format, int private)
2799.   {
2800. >     FILE *fp = NULL;
2801.       BIO *b = NULL;
2802.       int fd = -1, bflags, mode, binmode;

apps/apps.c:2801:5: 
2799.   {
2800.       FILE *fp = NULL;
2801. >     BIO *b = NULL;
2802.       int fd = -1, bflags, mode, binmode;
2803.   

apps/apps.c:2802:5: 
2800.       FILE *fp = NULL;
2801.       BIO *b = NULL;
2802. >     int fd = -1, bflags, mode, binmode;
2803.   
2804.       if (!private || filename == NULL || strcmp(filename, "-") == 0)

apps/apps.c:2804:10: Taking false branch
2802.       int fd = -1, bflags, mode, binmode;
2803.   
2804.       if (!private || filename == NULL || strcmp(filename, "-") == 0)
                 ^
2805.           return bio_open_default(filename, 'w', format);
2806.   

apps/apps.c:2804:21: Taking false branch
2802.       int fd = -1, bflags, mode, binmode;
2803.   
2804.       if (!private || filename == NULL || strcmp(filename, "-") == 0)
                            ^
2805.           return bio_open_default(filename, 'w', format);
2806.   

apps/apps.c:2804:41: Taking false branch
2802.       int fd = -1, bflags, mode, binmode;
2803.   
2804.       if (!private || filename == NULL || strcmp(filename, "-") == 0)
                                                ^
2805.           return bio_open_default(filename, 'w', format);
2806.   

apps/apps.c:2807:5: 
2805.           return bio_open_default(filename, 'w', format);
2806.   
2807. >     mode = O_WRONLY;
2808.   #ifdef O_CREAT
2809.       mode |= O_CREAT;

apps/apps.c:2809:5: 
2807.       mode = O_WRONLY;
2808.   #ifdef O_CREAT
2809. >     mode |= O_CREAT;
2810.   #endif
2811.   #ifdef O_TRUNC

apps/apps.c:2812:5: 
2810.   #endif
2811.   #ifdef O_TRUNC
2812. >     mode |= O_TRUNC;
2813.   #endif
2814.       binmode = istext(format);

apps/apps.c:2814:5: 
2812.       mode |= O_TRUNC;
2813.   #endif
2814. >     binmode = istext(format);
2815.       if (binmode) {
2816.   #ifdef O_BINARY

apps/apps.c:2739:1: start of procedure istext()
  2737.    * text and binary input/output on non-Unix platforms
  2738.    */
  2739. > static int istext(int format)
  2740.   {
  2741.       return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;

apps/apps.c:2741:12: Condition is true
  2739.   static int istext(int format)
  2740.   {
  2741.       return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;
                     ^
  2742.   }
  2743.   

apps/apps.c:2741:5: 
  2739.   static int istext(int format)
  2740.   {
  2741. >     return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;
  2742.   }
  2743.   

apps/apps.c:2742:1: return from a call to istext
  2740.   {
  2741.       return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;
  2742. > }
  2743.   
  2744.   BIO *dup_bio_in(int format)

apps/apps.c:2815:9: Taking true branch
2813.   #endif
2814.       binmode = istext(format);
2815.       if (binmode) {
                ^
2816.   #ifdef O_BINARY
2817.           mode |= O_BINARY;

apps/apps.c:2823:5: 
2821.       }
2822.   
2823. >     fd = open(filename, mode, 0600);
2824.       if (fd < 0)
2825.           goto err;

apps/apps.c:2824:9: Taking false branch
2822.   
2823.       fd = open(filename, mode, 0600);
2824.       if (fd < 0)
                ^
2825.           goto err;
2826.       fp = fdopen(fd, modestr('w', format));

apps/apps.c:2826:5: 
2824.       if (fd < 0)
2825.           goto err;
2826. >     fp = fdopen(fd, modestr('w', format));
2827.       if (fp == NULL)
2828.           goto err;

apps/apps.c:2766:1: start of procedure modestr()
  2764.   }
  2765.   
  2766. > static const char *modestr(char mode, int format)
  2767.   {
  2768.       OPENSSL_assert(mode == 'a' || mode == 'r' || mode == 'w');

apps/apps.c:2768:5: Condition is true
  2766.   static const char *modestr(char mode, int format)
  2767.   {
  2768.       OPENSSL_assert(mode == 'a' || mode == 'r' || mode == 'w');
              ^
  2769.   
  2770.       switch (mode) {

apps/apps.c:2770:5: 
  2768.       OPENSSL_assert(mode == 'a' || mode == 'r' || mode == 'w');
  2769.   
  2770. >     switch (mode) {
  2771.       case 'a':
  2772.           return istext(format) ? "a" : "ab";

apps/apps.c:2771:5: Switch condition is false. Skipping switch case
  2769.   
  2770.       switch (mode) {
  2771.       case 'a':
              ^
  2772.           return istext(format) ? "a" : "ab";
  2773.       case 'r':

apps/apps.c:2773:5: Switch condition is false. Skipping switch case
  2771.       case 'a':
  2772.           return istext(format) ? "a" : "ab";
  2773.       case 'r':
              ^
  2774.           return istext(format) ? "r" : "rb";
  2775.       case 'w':

apps/apps.c:2775:5: Switch condition is false. Skipping switch case
  2773.       case 'r':
  2774.           return istext(format) ? "r" : "rb";
  2775.       case 'w':
              ^
  2776.           return istext(format) ? "w" : "wb";
  2777.       }

apps/apps.c:2779:5: 
  2777.       }
  2778.       /* The assert above should make sure we never reach this point */
  2779. >     return NULL;
  2780.   }
  2781.   

apps/apps.c:2780:1: return from a call to modestr
  2778.       /* The assert above should make sure we never reach this point */
  2779.       return NULL;
  2780. > }
  2781.   
  2782.   static const char *modeverb(char mode)

apps/apps.c:2827:9: Taking false branch
2825.           goto err;
2826.       fp = fdopen(fd, modestr('w', format));
2827.       if (fp == NULL)
                ^
2828.           goto err;
2829.       bflags = BIO_CLOSE;

apps/apps.c:2829:5: 
2827.       if (fp == NULL)
2828.           goto err;
2829. >     bflags = BIO_CLOSE;
2830.       if (!binmode)
2831.           bflags |= BIO_FP_TEXT;

apps/apps.c:2830:10: Taking false branch
2828.           goto err;
2829.       bflags = BIO_CLOSE;
2830.       if (!binmode)
                 ^
2831.           bflags |= BIO_FP_TEXT;
2832.       b = BIO_new_fp(fp, bflags);

apps/apps.c:2832:5: Skipping BIO_new_fp(): empty list of specs
2830.       if (!binmode)
2831.           bflags |= BIO_FP_TEXT;
2832.       b = BIO_new_fp(fp, bflags);
            ^
2833.       if (b)
2834.           return b;

apps/apps.c:2833:9: Taking true branch
2831.           bflags |= BIO_FP_TEXT;
2832.       b = BIO_new_fp(fp, bflags);
2833.       if (b)
                ^
2834.           return b;
2835.   

apps/apps.c:2834:9: 
2832.       b = BIO_new_fp(fp, bflags);
2833.       if (b)
2834. >         return b;
2835.   
2836.    err:

BIO *bio_open_owner(const char *filename, int format, int private)
{
    FILE *fp = NULL;
    BIO *b = NULL;
    int fd = -1, bflags, mode, binmode;
    if (!private || filename == NULL || strcmp(filename, "-") == 0)
        return bio_open_default(filename, 'w', format);
    mode = O_WRONLY;
#ifdef O_CREAT
    mode |= O_CREAT;
#endif
#ifdef O_TRUNC
    mode |= O_TRUNC;
#endif
    binmode = istext(format);
    if (binmode) {
#ifdef O_BINARY
        mode |= O_BINARY;
#elif defined(_O_BINARY)
        mode |= _O_BINARY;
#endif
    }
    fd = open(filename, mode, 0600);
    if (fd < 0)
        goto err;
    fp = fdopen(fd, modestr('w', format));
    if (fp == NULL)
        goto err;
    bflags = BIO_CLOSE;
    if (!binmode)
        bflags |= BIO_FP_TEXT;
    b = BIO_new_fp(fp, bflags);
    if (b)
        return b;
 err:
    BIO_printf(bio_err, "%s: Can't open \"%s\" for writing, %s\n",
               opt_getprog(), filename, strerror(errno));
    ERR_print_errors(bio_err);
    if (fp)
        fclose(fp);
    else if (fd >= 0)
        close(fd);
    return NULL;
}
['BIO *bio_open_owner(const char *filename, int format, int private)\n{\n    FILE *fp = NULL;\n    BIO *b = NULL;\n    int fd = -1, bflags, mode, binmode;\n    if (!private || filename == NULL || strcmp(filename, "-") == 0)\n        return bio_open_default(filename, \'w\', format);\n    mode = O_WRONLY;\n#ifdef O_CREAT\n    mode |= O_CREAT;\n#endif\n#ifdef O_TRUNC\n    mode |= O_TRUNC;\n#endif\n    binmode = istext(format);\n    if (binmode) {\n#ifdef O_BINARY\n        mode |= O_BINARY;\n#elif defined(_O_BINARY)\n        mode |= _O_BINARY;\n#endif\n    }\n    fd = open(filename, mode, 0600);\n    if (fd < 0)\n        goto err;\n    fp = fdopen(fd, modestr(\'w\', format));\n    if (fp == NULL)\n        goto err;\n    bflags = BIO_CLOSE;\n    if (!binmode)\n        bflags |= BIO_FP_TEXT;\n    b = BIO_new_fp(fp, bflags);\n    if (b)\n        return b;\n err:\n    BIO_printf(bio_err, "%s: Can\'t open \\"%s\\" for writing, %s\\n",\n               opt_getprog(), filename, strerror(errno));\n    ERR_print_errors(bio_err);\n    if (fp)\n        fclose(fp);\n    else if (fd >= 0)\n        close(fd);\n    return NULL;\n}', 'static int istext(int format)\n{\n    return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;\n}', 'static const char *modestr(char mode, int format)\n{\n    OPENSSL_assert(mode == \'a\' || mode == \'r\' || mode == \'w\');\n    switch (mode) {\n    case \'a\':\n        return istext(format) ? "a" : "ab";\n    case \'r\':\n        return istext(format) ? "r" : "rb";\n    case \'w\':\n        return istext(format) ? "w" : "wb";\n    }\n    return NULL;\n}']