Skip to content

Commit 22a1b67

Browse files
committed
Fix possible resource leak (CWE-772)
In case of error, variable fd would go out of scope leaking the storage it points to.
1 parent e7511d8 commit 22a1b67

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

python-ethtool/ethtool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ static PyObject *get_devices(PyObject *self __unused, PyObject *args __unused)
9494
ret = fgets(buffer, 256, fd);
9595
ret = fgets(buffer, 256, fd);
9696
if (!ret) {
97+
fclose(fd);
9798
return PyErr_SetFromErrno(PyExc_OSError);
9899
}
99100

0 commit comments

Comments
 (0)