git.samba.org
/
samba.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
tdb: Fix CID 1034841 Resource leak
[samba.git]
/
lib
/
tdb
/
test
/
run-incompatible.c
diff --git
a/lib/tdb/test/run-incompatible.c
b/lib/tdb/test/run-incompatible.c
index b8e95b5e77877e57de0115d072bf0d0b6c11a5a8..5f1b586f9cc3df0995a20655dda7dd3a99d9281e 100644
(file)
--- 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;
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;
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);
close(fd);
+ if (nread != sizeof(hdr)) {
+ return -1;
+ }
return hdr.rwlocks;
}
return hdr.rwlocks;
}