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


apps/apps.c:2793:1: start of procedure bio_open_owner()
2791.    * Open a file for writing, owner-read-only.
2792.    */
2793. > BIO *bio_open_owner(const char *filename, int format, int private)
2794.   {
2795.       FILE *fp = NULL;

apps/apps.c:2795:5: 
2793.   BIO *bio_open_owner(const char *filename, int format, int private)
2794.   {
2795. >     FILE *fp = NULL;
2796.       BIO *b = NULL;
2797.       int fd = -1, bflags, mode, textmode;

apps/apps.c:2796:5: 
2794.   {
2795.       FILE *fp = NULL;
2796. >     BIO *b = NULL;
2797.       int fd = -1, bflags, mode, textmode;
2798.   

apps/apps.c:2797:5: 
2795.       FILE *fp = NULL;
2796.       BIO *b = NULL;
2797. >     int fd = -1, bflags, mode, textmode;
2798.   
2799.       if (!private || filename == NULL || strcmp(filename, "-") == 0)

apps/apps.c:2799:10: Taking false branch
2797.       int fd = -1, bflags, mode, textmode;
2798.   
2799.       if (!private || filename == NULL || strcmp(filename, "-") == 0)
                 ^
2800.           return bio_open_default(filename, 'w', format);
2801.   

apps/apps.c:2799:21: Taking false branch
2797.       int fd = -1, bflags, mode, textmode;
2798.   
2799.       if (!private || filename == NULL || strcmp(filename, "-") == 0)
                            ^
2800.           return bio_open_default(filename, 'w', format);
2801.   

apps/apps.c:2799:41: Taking false branch
2797.       int fd = -1, bflags, mode, textmode;
2798.   
2799.       if (!private || filename == NULL || strcmp(filename, "-") == 0)
                                                ^
2800.           return bio_open_default(filename, 'w', format);
2801.   

apps/apps.c:2802:5: 
2800.           return bio_open_default(filename, 'w', format);
2801.   
2802. >     mode = O_WRONLY;
2803.   #ifdef O_CREAT
2804.       mode |= O_CREAT;

apps/apps.c:2804:5: 
2802.       mode = O_WRONLY;
2803.   #ifdef O_CREAT
2804. >     mode |= O_CREAT;
2805.   #endif
2806.   #ifdef O_TRUNC

apps/apps.c:2807:5: 
2805.   #endif
2806.   #ifdef O_TRUNC
2807. >     mode |= O_TRUNC;
2808.   #endif
2809.       textmode = istext(format);

apps/apps.c:2809:5: 
2807.       mode |= O_TRUNC;
2808.   #endif
2809. >     textmode = istext(format);
2810.       if (!textmode) {
2811.   #ifdef O_BINARY

apps/apps.c:2734:1: start of procedure istext()
  2732.    * text and binary input/output on non-Unix platforms
  2733.    */
  2734. > static int istext(int format)
  2735.   {
  2736.       return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;

apps/apps.c:2736:12: Condition is true
  2734.   static int istext(int format)
  2735.   {
  2736.       return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;
                     ^
  2737.   }
  2738.   

apps/apps.c:2736:5: 
  2734.   static int istext(int format)
  2735.   {
  2736. >     return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;
  2737.   }
  2738.   

apps/apps.c:2737:1: return from a call to istext
  2735.   {
  2736.       return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;
  2737. > }
  2738.   
  2739.   BIO *dup_bio_in(int format)

apps/apps.c:2810:10: Taking false branch
2808.   #endif
2809.       textmode = istext(format);
2810.       if (!textmode) {
                 ^
2811.   #ifdef O_BINARY
2812.           mode |= O_BINARY;

apps/apps.c:2828:9: 
2826.       else
2827.   #endif
2828. >         fd = open(filename, mode, 0600);
2829.       if (fd < 0)
2830.           goto err;

apps/apps.c:2829:9: Taking false branch
2827.   #endif
2828.           fd = open(filename, mode, 0600);
2829.       if (fd < 0)
                ^
2830.           goto err;
2831.       fp = fdopen(fd, modestr('w', format));

apps/apps.c:2831:5: 
2829.       if (fd < 0)
2830.           goto err;
2831. >     fp = fdopen(fd, modestr('w', format));
2832.       if (fp == NULL)
2833.           goto err;

apps/apps.c:2761:1: start of procedure modestr()
  2759.   }
  2760.   
  2761. > static const char *modestr(char mode, int format)
  2762.   {
  2763.       OPENSSL_assert(mode == 'a' || mode == 'r' || mode == 'w');

apps/apps.c:2763:5: Condition is true
  2761.   static const char *modestr(char mode, int format)
  2762.   {
  2763.       OPENSSL_assert(mode == 'a' || mode == 'r' || mode == 'w');
              ^
  2764.   
  2765.       switch (mode) {

apps/apps.c:2765:5: 
  2763.       OPENSSL_assert(mode == 'a' || mode == 'r' || mode == 'w');
  2764.   
  2765. >     switch (mode) {
  2766.       case 'a':
  2767.           return istext(format) ? "a" : "ab";

apps/apps.c:2766:5: Switch condition is false. Skipping switch case
  2764.   
  2765.       switch (mode) {
  2766.       case 'a':
              ^
  2767.           return istext(format) ? "a" : "ab";
  2768.       case 'r':

apps/apps.c:2768:5: Switch condition is false. Skipping switch case
  2766.       case 'a':
  2767.           return istext(format) ? "a" : "ab";
  2768.       case 'r':
              ^
  2769.           return istext(format) ? "r" : "rb";
  2770.       case 'w':

apps/apps.c:2770:5: Switch condition is false. Skipping switch case
  2768.       case 'r':
  2769.           return istext(format) ? "r" : "rb";
  2770.       case 'w':
              ^
  2771.           return istext(format) ? "w" : "wb";
  2772.       }

apps/apps.c:2774:5: 
  2772.       }
  2773.       /* The assert above should make sure we never reach this point */
  2774. >     return NULL;
  2775.   }
  2776.   

apps/apps.c:2775:1: return from a call to modestr
  2773.       /* The assert above should make sure we never reach this point */
  2774.       return NULL;
  2775. > }
  2776.   
  2777.   static const char *modeverb(char mode)

apps/apps.c:2832:9: Taking false branch
2830.           goto err;
2831.       fp = fdopen(fd, modestr('w', format));
2832.       if (fp == NULL)
                ^
2833.           goto err;
2834.       bflags = BIO_CLOSE;

apps/apps.c:2834:5: 
2832.       if (fp == NULL)
2833.           goto err;
2834. >     bflags = BIO_CLOSE;
2835.       if (textmode)
2836.           bflags |= BIO_FP_TEXT;

apps/apps.c:2835:9: Taking false branch
2833.           goto err;
2834.       bflags = BIO_CLOSE;
2835.       if (textmode)
                ^
2836.           bflags |= BIO_FP_TEXT;
2837.       b = BIO_new_fp(fp, bflags);

apps/apps.c:2837:5: Skipping BIO_new_fp(): empty list of specs
2835.       if (textmode)
2836.           bflags |= BIO_FP_TEXT;
2837.       b = BIO_new_fp(fp, bflags);
            ^
2838.       if (b)
2839.           return b;

apps/apps.c:2838:9: Taking true branch
2836.           bflags |= BIO_FP_TEXT;
2837.       b = BIO_new_fp(fp, bflags);
2838.       if (b)
                ^
2839.           return b;
2840.   

apps/apps.c:2839:9: 
2837.       b = BIO_new_fp(fp, bflags);
2838.       if (b)
2839. >         return b;
2840.   
2841.    err:

BIO *bio_open_owner(const char *filename, int format, int private)
{
    FILE *fp = NULL;
    BIO *b = NULL;
    int fd = -1, bflags, mode, textmode;
    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
    textmode = istext(format);
    if (!textmode) {
#ifdef O_BINARY
        mode |= O_BINARY;
#elif defined(_O_BINARY)
        mode |= _O_BINARY;
#endif
    }
#ifdef OPENSSL_SYS_VMS
    if (!textmode)
        fd = open(filename, mode, 0600, "ctx=bin");
    else
#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 (textmode)
        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, textmode;\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    textmode = istext(format);\n    if (!textmode) {\n#ifdef O_BINARY\n        mode |= O_BINARY;\n#elif defined(_O_BINARY)\n        mode |= _O_BINARY;\n#endif\n    }\n#ifdef OPENSSL_SYS_VMS\n    if (!textmode)\n        fd = open(filename, mode, 0600, "ctx=bin");\n    else\n#endif\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 (textmode)\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}']