summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e61246f)
raw | patch | inline | side by side (parent: e61246f)
author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 4 Dec 2015 20:56:40 +0000 (21:56 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Sat, 5 Dec 2015 07:52:29 +0000 (08:52 +0100) |
If open returns 0 we leak fd.
CID #38016
Signed-off-by: Florian Forster <octo@collectd.org>
CID #38016
Signed-off-by: Florian Forster <octo@collectd.org>
src/multimeter.c | patch | blob | history |
diff --git a/src/multimeter.c b/src/multimeter.c
index 775eb57e27bff64201f81e83cf6528c36fa0608e..03608e6cfe5e61110e13552f43f7fd8e5963c46c 100644 (file)
--- a/src/multimeter.c
+++ b/src/multimeter.c
for (i = 0; i < 10; i++)
{
- device[strlen(device)-1] = i + '0';
+ device[strlen(device)-1] = i + '0';
- if ((fd = open(device, O_RDWR | O_NOCTTY)) > 0)
+ if ((fd = open(device, O_RDWR | O_NOCTTY)) != -1)
{
struct termios tios;
int rts = TIOCM_RTS;
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &tios);
ioctl(fd, TIOCMBIC, &rts);
-
+
if (multimeter_read_value (&value) < -1)
{
close (fd);