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


apps/openssl.c:334:1: start of procedure bio_open_owner()
332.    * Open a file for writing, owner-read-only.
333.    */
334. > BIO *bio_open_owner(const char *filename, int format, int private)
335.   {
336.       FILE *fp = NULL;

apps/openssl.c:336:5: 
334.   BIO *bio_open_owner(const char *filename, int format, int private)
335.   {
336. >     FILE *fp = NULL;
337.       BIO *b = NULL;
338.       int fd = -1, bflags, mode, binmode;

apps/openssl.c:337:5: 
335.   {
336.       FILE *fp = NULL;
337. >     BIO *b = NULL;
338.       int fd = -1, bflags, mode, binmode;
339.   

apps/openssl.c:338:5: 
336.       FILE *fp = NULL;
337.       BIO *b = NULL;
338. >     int fd = -1, bflags, mode, binmode;
339.   
340.       if (!private || filename == NULL || strcmp(filename, "-") == 0)

apps/openssl.c:340:10: Taking false branch
338.       int fd = -1, bflags, mode, binmode;
339.   
340.       if (!private || filename == NULL || strcmp(filename, "-") == 0)
                ^
341.           return bio_open_default(filename, 'w', format);
342.   

apps/openssl.c:340:21: Taking false branch
338.       int fd = -1, bflags, mode, binmode;
339.   
340.       if (!private || filename == NULL || strcmp(filename, "-") == 0)
                           ^
341.           return bio_open_default(filename, 'w', format);
342.   

apps/openssl.c:340:41: Taking false branch
338.       int fd = -1, bflags, mode, binmode;
339.   
340.       if (!private || filename == NULL || strcmp(filename, "-") == 0)
                                               ^
341.           return bio_open_default(filename, 'w', format);
342.   

apps/openssl.c:343:5: 
341.           return bio_open_default(filename, 'w', format);
342.   
343. >     mode = O_WRONLY;
344.   #ifdef O_CREAT
345.       mode |= O_CREAT;

apps/openssl.c:345:5: 
343.       mode = O_WRONLY;
344.   #ifdef O_CREAT
345. >     mode |= O_CREAT;
346.   #endif
347.   #ifdef O_TRUNC

apps/openssl.c:348:5: 
346.   #endif
347.   #ifdef O_TRUNC
348. >     mode |= O_TRUNC;
349.   #endif
350.       binmode = !(format & B_FORMAT_TEXT);

apps/openssl.c:350:17: Condition is false
348.       mode |= O_TRUNC;
349.   #endif
350.       binmode = !(format & B_FORMAT_TEXT);
                       ^
351.       if (binmode) {
352.   #ifdef O_BINARY

apps/openssl.c:350:15: 
348.       mode |= O_TRUNC;
349.   #endif
350. >     binmode = !(format & B_FORMAT_TEXT);
351.       if (binmode) {
352.   #ifdef O_BINARY

apps/openssl.c:350:5: 
348.       mode |= O_TRUNC;
349.   #endif
350. >     binmode = !(format & B_FORMAT_TEXT);
351.       if (binmode) {
352.   #ifdef O_BINARY

apps/openssl.c:351:9: Taking true branch
349.   #endif
350.       binmode = !(format & B_FORMAT_TEXT);
351.       if (binmode) {
               ^
352.   #ifdef O_BINARY
353.           mode |= O_BINARY;

apps/openssl.c:359:5: 
357.       }
358.   
359. >     fd = open(filename, mode, 0600);
360.       if (fd < 0)
361.           goto err;

apps/openssl.c:360:9: Taking false branch
358.   
359.       fd = open(filename, mode, 0600);
360.       if (fd < 0)
               ^
361.           goto err;
362.       fp = fdopen(fd, modestr('w', format));

apps/openssl.c:362:5: 
360.       if (fd < 0)
361.           goto err;
362. >     fp = fdopen(fd, modestr('w', format));
363.       if (fp == NULL)
364.           goto err;

apps/openssl.c:302:1: start of procedure modestr()
  300.   }
  301.   
  302. > static const char *modestr(char mode, int format)
  303.   {
  304.       OPENSSL_assert(mode == 'a' || mode == 'r' || mode == 'w');

apps/openssl.c:304:5: Condition is true
  302.   static const char *modestr(char mode, int format)
  303.   {
  304.       OPENSSL_assert(mode == 'a' || mode == 'r' || mode == 'w');
             ^
  305.   
  306.       switch (mode) {

apps/openssl.c:306:5: 
  304.       OPENSSL_assert(mode == 'a' || mode == 'r' || mode == 'w');
  305.   
  306. >     switch (mode) {
  307.       case 'a':
  308.           return (format) & B_FORMAT_TEXT ? "ab" : "a";

apps/openssl.c:307:5: Switch condition is false. Skipping switch case
  305.   
  306.       switch (mode) {
  307.       case 'a':
             ^
  308.           return (format) & B_FORMAT_TEXT ? "ab" : "a";
  309.       case 'r':

apps/openssl.c:309:5: Switch condition is false. Skipping switch case
  307.       case 'a':
  308.           return (format) & B_FORMAT_TEXT ? "ab" : "a";
  309.       case 'r':
             ^
  310.           return (format) & B_FORMAT_TEXT ? "rb" : "r";
  311.       case 'w':

apps/openssl.c:311:5: Switch condition is false. Skipping switch case
  309.       case 'r':
  310.           return (format) & B_FORMAT_TEXT ? "rb" : "r";
  311.       case 'w':
             ^
  312.           return (format) & B_FORMAT_TEXT ? "wb" : "w";
  313.       }

apps/openssl.c:315:5: 
  313.       }
  314.       /* The assert above should make sure we never reach this point */
  315. >     return NULL;
  316.   }
  317.   

apps/openssl.c:316:1: return from a call to modestr
  314.       /* The assert above should make sure we never reach this point */
  315.       return NULL;
  316. > }
  317.   
  318.   static const char *modeverb(char mode)

apps/openssl.c:363:9: Taking false branch
361.           goto err;
362.       fp = fdopen(fd, modestr('w', format));
363.       if (fp == NULL)
               ^
364.           goto err;
365.       bflags = BIO_CLOSE;

apps/openssl.c:365:5: 
363.       if (fp == NULL)
364.           goto err;
365. >     bflags = BIO_CLOSE;
366.       if (!binmode)
367.           bflags |= BIO_FP_TEXT;

apps/openssl.c:366:10: Taking false branch
364.           goto err;
365.       bflags = BIO_CLOSE;
366.       if (!binmode)
                ^
367.           bflags |= BIO_FP_TEXT;
368.       b = BIO_new_fp(fp, bflags);

apps/openssl.c:368:5: Skipping BIO_new_fp(): empty list of specs
366.       if (!binmode)
367.           bflags |= BIO_FP_TEXT;
368.       b = BIO_new_fp(fp, bflags);
           ^
369.       if (b)
370.           return b;

apps/openssl.c:369:9: Taking true branch
367.           bflags |= BIO_FP_TEXT;
368.       b = BIO_new_fp(fp, bflags);
369.       if (b)
               ^
370.           return b;
371.   

apps/openssl.c:370:9: 
368.       b = BIO_new_fp(fp, bflags);
369.       if (b)
370. >         return b;
371.   
372.    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 = !(format & B_FORMAT_TEXT);
    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 = !(format & B_FORMAT_TEXT);\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 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 (format) & B_FORMAT_TEXT ? "ab" : "a";\n    case \'r\':\n        return (format) & B_FORMAT_TEXT ? "rb" : "r";\n    case \'w\':\n        return (format) & B_FORMAT_TEXT ? "wb" : "w";\n    }\n    return NULL;\n}']