Ticket #10385: 0001-Fix-Coverity-CID-991761-double-close.patch

File 0001-Fix-Coverity-CID-991761-double-close.patch, 935 bytes (added by noryb009, 10 years ago)
  • src/bin/chop.c

    From e0409eabe2bf9e758c30aadfa31c2a70489293af Mon Sep 17 00:00:00 2001
    From: noryb009 <noryb009@hotmail.com>
    Date: Mon, 6 Jan 2014 09:16:49 -0500
    Subject: [PATCH] Fix Coverity CID 991761: double close
    
    ---
     src/bin/chop.c | 9 +++++----
     1 file changed, 5 insertions(+), 4 deletions(-)
    
    diff --git a/src/bin/chop.c b/src/bin/chop.c
    index bcde16b..fb705a1 100644
    a b chop_file(int fdin, char *fname, off_t fsize)  
    200200        if (beg >= end) {
    201201            // read in another block
    202202            got = read(fdin, Block, BLOCKSIZE);
    203             if (got <= 0)
     203            if (got <= 0) {
     204                // if open, close the last output file
     205                if (open_next_file == false)
     206                    close(fdout);
    204207                break;
     208            }
    205209           
    206210            beg = Block;
    207211            end = Block + got - 1;
    chop_file(int fdin, char *fname, off_t fsize)  
    239243            open_next_file = true;
    240244        }
    241245    }
    242    
    243     // close up the last output file
    244     close(fdout);
    245246}