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


apps/openssl.c:305:1: start of procedure bio_open_owner()
303.    * Open a file for writing, owner-read-only.
304.    */
305. > BIO *bio_open_owner(const char *filename, const char *modestr, int private)
306.   {
307.       FILE *fp = NULL;

apps/openssl.c:307:5: 
305.   BIO *bio_open_owner(const char *filename, const char *modestr, int private)
306.   {
307. >     FILE *fp = NULL;
308.       BIO *b = NULL;
309.       int fd = -1, bflags, mode, binmode;

apps/openssl.c:308:5: 
306.   {
307.       FILE *fp = NULL;
308. >     BIO *b = NULL;
309.       int fd = -1, bflags, mode, binmode;
310.   

apps/openssl.c:309:5: 
307.       FILE *fp = NULL;
308.       BIO *b = NULL;
309. >     int fd = -1, bflags, mode, binmode;
310.   
311.       if (!private || filename == NULL || strcmp(filename, "-") == 0)

apps/openssl.c:311:10: Taking false branch
309.       int fd = -1, bflags, mode, binmode;
310.   
311.       if (!private || filename == NULL || strcmp(filename, "-") == 0)
                ^
312.           return bio_open_default(filename, modestr);
313.   

apps/openssl.c:311:21: Taking false branch
309.       int fd = -1, bflags, mode, binmode;
310.   
311.       if (!private || filename == NULL || strcmp(filename, "-") == 0)
                           ^
312.           return bio_open_default(filename, modestr);
313.   

apps/openssl.c:311:41: Taking false branch
309.       int fd = -1, bflags, mode, binmode;
310.   
311.       if (!private || filename == NULL || strcmp(filename, "-") == 0)
                                               ^
312.           return bio_open_default(filename, modestr);
313.   

apps/openssl.c:314:5: 
312.           return bio_open_default(filename, modestr);
313.   
314. >     mode = O_WRONLY;
315.   #ifdef O_CREAT
316.       mode |= O_CREAT;

apps/openssl.c:316:5: 
314.       mode = O_WRONLY;
315.   #ifdef O_CREAT
316. >     mode |= O_CREAT;
317.   #endif
318.   #ifdef O_TRUNC

apps/openssl.c:319:5: 
317.   #endif
318.   #ifdef O_TRUNC
319. >     mode |= O_TRUNC;
320.   #endif
321.       binmode = strchr(modestr, 'b') != NULL;

apps/openssl.c:321:15: Condition is true
319.       mode |= O_TRUNC;
320.   #endif
321.       binmode = strchr(modestr, 'b') != NULL;
                     ^
322.       if (binmode) {
323.   #ifdef O_BINARY

apps/openssl.c:321:5: 
319.       mode |= O_TRUNC;
320.   #endif
321. >     binmode = strchr(modestr, 'b') != NULL;
322.       if (binmode) {
323.   #ifdef O_BINARY

apps/openssl.c:322:9: Taking true branch
320.   #endif
321.       binmode = strchr(modestr, 'b') != NULL;
322.       if (binmode) {
               ^
323.   #ifdef O_BINARY
324.           mode |= O_BINARY;

apps/openssl.c:330:5: 
328.       }
329.   
330. >     fd = open(filename, mode, 0600);
331.       if (fd < 0)
332.           goto err;

apps/openssl.c:331:9: Taking false branch
329.   
330.       fd = open(filename, mode, 0600);
331.       if (fd < 0)
               ^
332.           goto err;
333.       fp = fdopen(fd, modestr);

apps/openssl.c:333:5: 
331.       if (fd < 0)
332.           goto err;
333. >     fp = fdopen(fd, modestr);
334.       if (fp == NULL)
335.           goto err;

apps/openssl.c:334:9: Taking false branch
332.           goto err;
333.       fp = fdopen(fd, modestr);
334.       if (fp == NULL)
               ^
335.           goto err;
336.       bflags = BIO_CLOSE;

apps/openssl.c:336:5: 
334.       if (fp == NULL)
335.           goto err;
336. >     bflags = BIO_CLOSE;
337.       if (!binmode)
338.           bflags |= BIO_FP_TEXT;

apps/openssl.c:337:10: Taking false branch
335.           goto err;
336.       bflags = BIO_CLOSE;
337.       if (!binmode)
                ^
338.           bflags |= BIO_FP_TEXT;
339.       b = BIO_new_fp(fp, bflags);

apps/openssl.c:339:5: Skipping BIO_new_fp(): empty list of specs
337.       if (!binmode)
338.           bflags |= BIO_FP_TEXT;
339.       b = BIO_new_fp(fp, bflags);
           ^
340.       if (b)
341.           return b;

apps/openssl.c:340:9: Taking true branch
338.           bflags |= BIO_FP_TEXT;
339.       b = BIO_new_fp(fp, bflags);
340.       if (b)
               ^
341.           return b;
342.   

apps/openssl.c:341:9: 
339.       b = BIO_new_fp(fp, bflags);
340.       if (b)
341. >         return b;
342.   
343.    err:

BIO *bio_open_owner(const char *filename, const char *modestr, 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, modestr);
    mode = O_WRONLY;
#ifdef O_CREAT
    mode |= O_CREAT;
#endif
#ifdef O_TRUNC
    mode |= O_TRUNC;
#endif
    binmode = strchr(modestr, 'b') != NULL;
    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);
    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, const char *modestr, 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, modestr);\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 = strchr(modestr, \'b\') != NULL;\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);\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}']