summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremie Koenig <jk@jk.fr.eu.org>2010-08-13 19:05:13 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2010-08-18 01:25:26 +0200
commit5d011324a721d7cf3babfe6aa068e247c7f27f42 (patch)
tree26cb89e195d98e698bc6b330d6c0654a9ec663fd
parentd76613f23eec2a66f4727c69fcec3b5e3be3da22 (diff)
update_pid_entries(): fix awkwardly indented uninitialized memory leak
* procfs_pid_files.c (update_pid_entries): Replace dynamic allocation of `stat' with automatic allocation. Memset `stat' to 0.
-rw-r--r--procfs_pid_files.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/procfs_pid_files.c b/procfs_pid_files.c
index 4686153..d44a2a2 100644
--- a/procfs_pid_files.c
+++ b/procfs_pid_files.c
@@ -46,14 +46,12 @@ update_pid_entries (struct procfs_dir *dir, const char *name,
time_t timestamp,
const char *symlink_target)
{
- struct procfs_dir_entry *dir_entry;
- struct stat *stat = (struct stat *) malloc (sizeof (struct stat));
- stat->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH;
+ struct stat stat;
- dir_entry = update_entries_list (dir, name, stat,
- timestamp, symlink_target);
+ memset (&stat, 0, sizeof stat);
+ stat->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH;
- return dir_entry;
+ return update_entries_list (dir, name, &stat, timestamp, symlink_target);
}
/* Creates files to store process information for DIR