Skip to content

Commit 8ac9b5e

Browse files
dunbehlendorf
authored andcommittedOct 6, 2014
Cleanup struct zed_conf vars in zed_conf_destroy
Reset struct zed_conf file descriptors to -1 after close(), and pointers to NULL after free(). Signed-off-by: Chris Dunlap <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Issue #2756
1 parent 56697c4 commit 8ac9b5e

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed
 

‎cmd/zed/zed_conf.c

+16-10
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ zed_conf_destroy(struct zed_conf *zcp)
9999
zed_log_msg(LOG_WARNING,
100100
"Failed to close state file \"%s\": %s",
101101
zcp->state_file, strerror(errno));
102+
zcp->state_fd = -1;
102103
}
103104
if (zcp->pid_file) {
104105
if ((unlink(zcp->pid_file) < 0) && (errno != ENOENT))
@@ -113,21 +114,26 @@ zed_conf_destroy(struct zed_conf *zcp)
113114
zcp->pid_file, strerror(errno));
114115
zcp->pid_fd = -1;
115116
}
116-
if (zcp->conf_file)
117+
if (zcp->conf_file) {
117118
free(zcp->conf_file);
118-
119-
if (zcp->pid_file)
119+
zcp->conf_file = NULL;
120+
}
121+
if (zcp->pid_file) {
120122
free(zcp->pid_file);
121-
122-
if (zcp->zedlet_dir)
123+
zcp->pid_file = NULL;
124+
}
125+
if (zcp->zedlet_dir) {
123126
free(zcp->zedlet_dir);
124-
125-
if (zcp->state_file)
127+
zcp->zedlet_dir = NULL;
128+
}
129+
if (zcp->state_file) {
126130
free(zcp->state_file);
127-
128-
if (zcp->zedlets)
131+
zcp->state_file = NULL;
132+
}
133+
if (zcp->zedlets) {
129134
zed_strings_destroy(zcp->zedlets);
130-
135+
zcp->zedlets = NULL;
136+
}
131137
free(zcp);
132138
}
133139

0 commit comments

Comments
 (0)