[libcamera-devel] [PATCH 2/4] test: ipc: unixsocket: Close open fds on error paths

Umang Jain email at uajain.com
Mon Apr 13 12:46:53 CEST 2020


Pointed out by Coverity DefectId=279052

Signed-off-by: Umang Jain <email at uajain.com>
---
 test/ipc/unixsocket.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp
index 5348f35..4fc6606 100644
--- a/test/ipc/unixsocket.cpp
+++ b/test/ipc/unixsocket.cpp
@@ -470,8 +470,10 @@ private:
 		int size = 0;
 		for (unsigned int i = 0; i < num; i++) {
 			int clone = dup(fd);
-			if (clone < 0)
+			if (clone < 0) {
+				close(fd);
 				return clone;
+			}
 
 			size += calculateLength(clone);
 			message->fds.push_back(clone);
-- 
2.26.0



More information about the libcamera-devel mailing list