From 1b8c07ac7d51eb2a1957d79ea05b170106a9c0e8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 8 Mar 2015 19:18:21 +0000 Subject: [PATCH] tdb: Fix CID 1034841 Resource leak Signed-off-by: Volker Lendecke Reviewed-by: Ira Cooper --- lib/tdb/test/run-incompatible.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/tdb/test/run-incompatible.c b/lib/tdb/test/run-incompatible.c index b8e95b5e778..5f1b586f9cc 100644 --- a/lib/tdb/test/run-incompatible.c +++ b/lib/tdb/test/run-incompatible.c @@ -28,15 +28,17 @@ static void log_fn(struct tdb_context *tdb, enum tdb_debug_level level, const ch static unsigned int hdr_rwlocks(const char *fname) { struct tdb_header hdr; + ssize_t nread; int fd = open(fname, O_RDONLY); if (fd == -1) return -1; - if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) - return -1; - + nread = read(fd, &hdr, sizeof(hdr)); close(fd); + if (nread != sizeof(hdr)) { + return -1; + } return hdr.rwlocks; } -- 2.11.4.GIT