$ cppcheck scm/abrt/src/hooks/abrt-hook-ccpp.c
Checking scm/abrt/src/hooks/abrt-hook-ccpp.c...
[scm/abrt/src/hooks/abrt-hook-ccpp.c:296]: (error) Resource leak: user_core_fd
$ cppcheck scm/abrt/src/hooks/abrt-hook-ccpp.c
Checking scm/abrt/src/hooks/abrt-hook-ccpp.c...
[scm/abrt/src/hooks/abrt-hook-ccpp.c:303]: (error) Resource leak: user_core_fd
---
src/hooks/abrt-hook-ccpp.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
index 52d006f..dad7a2e 100644
--- a/src/hooks/abrt-hook-ccpp.c
+++ b/src/hooks/abrt-hook-ccpp.c
@@ -293,12 +293,14 @@ static int open_user_core(const char *user_pwd, uid_t uid, pid_t
pid, char **per
/* kernel internal dumper checks this too: if (inode->i_uid != current->fsuid)
<fail>, need to mimic? */
) {
perror_msg("%s/%s is not a regular file with link count 1", user_pwd,
core_basename);
+ close(user_core_fd);
return -1;
}
if (ftruncate(user_core_fd, 0) != 0) {
/* perror first, otherwise unlink may trash errno */
perror_msg("truncate %s/%s", user_pwd, core_basename);
unlink(core_basename);
+ close(user_core_fd);
return -1;
}
--
1.7.1
Show replies by date