|
From: Mark W. <ma...@so...> - 2021-12-02 13:46:32
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=16ea9763be8b67f159df331cb294005976005513 commit 16ea9763be8b67f159df331cb294005976005513 Author: Mark Wielaard <ma...@kl...> Date: Thu Dec 2 14:41:44 2021 +0100 valgrind-di-server.c: Fix minor file descriptor leak on error In handle_transaction when a file descriptor is opened for a file, but then cannot be stat or the file turns out to be zero size we leak the file descriptor. Call close (fd) before reporting error. Diff: --- auxprogs/valgrind-di-server.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/auxprogs/valgrind-di-server.c b/auxprogs/valgrind-di-server.c index c6809bc3a9..a3357c004a 100644 --- a/auxprogs/valgrind-di-server.c +++ b/auxprogs/valgrind-di-server.c @@ -774,10 +774,12 @@ static Bool handle_transaction ( int conn_no ) int r = fstat(fd, &stat_buf); if (r != 0) { res = mk_Frame_asciiz("FAIL", "OPEN: cannot stat file"); + close(fd); ok = False; } if (ok && stat_buf.st_size == 0) { res = mk_Frame_asciiz("FAIL", "OPEN: file has zero size"); + close(fd); ok = False; } if (ok) { |