Fix leak of file descriptor in error path of bc_calc()
authorJens Axboe <axboe@fb.com>
Fri, 11 Apr 2014 17:27:34 +0000 (11:27 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 11 Apr 2014 17:27:34 +0000 (11:27 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
options.c

index 5c372b6964c0eb078737732131cbbb63c7541f10..9096a322bbc089db652662f8a1b04defd3f228b3 100644 (file)
--- a/options.c
+++ b/options.c
@@ -3656,8 +3656,10 @@ static char *bc_calc(char *str)
                return NULL;
 
        ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
-       if (ret <= 0)
+       if (ret <= 0) {
+               pclose(f);
                return NULL;
+       }
 
        pclose(f);
        buf[(tmp - str) + ret - 1] = '\0';