summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2010-10-24 15:41:23 +0000
committerpjd <pjd@FreeBSD.org>2010-10-24 15:41:23 +0000
commit8b3f940d7700d33b75365957beffb0d4b674016a (patch)
tree1ce33638b3000914f0a95961f1e7ec1b9abba62e /sbin
parent0b068ae424b27012aabdbaf4ed78550c69405f28 (diff)
downloadFreeBSD-src-8b3f940d7700d33b75365957beffb0d4b674016a.zip
FreeBSD-src-8b3f940d7700d33b75365957beffb0d4b674016a.tar.gz
Plug memory leaks.
Found with: valgrind MFC after: 3 days
Diffstat (limited to 'sbin')
-rw-r--r--sbin/hastd/parse.y24
-rw-r--r--sbin/hastd/primary.c1
-rw-r--r--sbin/hastd/synch.h2
3 files changed, 27 insertions, 0 deletions
diff --git a/sbin/hastd/parse.y b/sbin/hastd/parse.y
index ca575cf..d37e6db 100644
--- a/sbin/hastd/parse.y
+++ b/sbin/hastd/parse.y
@@ -264,6 +264,7 @@ control_statement: CONTROL STR
sizeof(depth0_control)) >=
sizeof(depth0_control)) {
pjdlog_error("control argument is too long.");
+ free($2);
return (1);
}
break;
@@ -274,12 +275,14 @@ control_statement: CONTROL STR
sizeof(lconfig->hc_controladdr)) >=
sizeof(lconfig->hc_controladdr)) {
pjdlog_error("control argument is too long.");
+ free($2);
return (1);
}
break;
default:
assert(!"control at wrong depth level");
}
+ free($2);
}
;
@@ -291,6 +294,7 @@ listen_statement: LISTEN STR
sizeof(depth0_listen)) >=
sizeof(depth0_listen)) {
pjdlog_error("listen argument is too long.");
+ free($2);
return (1);
}
break;
@@ -301,12 +305,14 @@ listen_statement: LISTEN STR
sizeof(lconfig->hc_listenaddr)) >=
sizeof(lconfig->hc_listenaddr)) {
pjdlog_error("listen argument is too long.");
+ free($2);
return (1);
}
break;
default:
assert(!"listen at wrong depth level");
}
+ free($2);
}
;
@@ -357,6 +363,7 @@ exec_statement: EXEC STR
if (strlcpy(depth0_exec, $2, sizeof(depth0_exec)) >=
sizeof(depth0_exec)) {
pjdlog_error("Exec path is too long.");
+ free($2);
return (1);
}
break;
@@ -367,12 +374,14 @@ exec_statement: EXEC STR
sizeof(curres->hr_exec)) >=
sizeof(curres->hr_exec)) {
pjdlog_error("Exec path is too long.");
+ free($2);
return (1);
}
break;
default:
assert(!"exec at wrong depth level");
}
+ free($2);
}
;
@@ -386,6 +395,7 @@ node_start: STR
{
switch (isitme($1)) {
case -1:
+ free($1);
return (1);
case 0:
break;
@@ -395,6 +405,7 @@ node_start: STR
default:
assert(!"invalid isitme() return value");
}
+ free($1);
}
;
@@ -482,14 +493,17 @@ resource_start: STR
curres = calloc(1, sizeof(*curres));
if (curres == NULL) {
pjdlog_error("Unable to allocate memory for resource.");
+ free($1);
return (1);
}
if (strlcpy(curres->hr_name, $1,
sizeof(curres->hr_name)) >=
sizeof(curres->hr_name)) {
pjdlog_error("Resource name is too long.");
+ free($1);
return (1);
}
+ free($1);
curres->hr_role = HAST_ROLE_INIT;
curres->hr_previous_role = HAST_ROLE_INIT;
curres->hr_replication = -1;
@@ -530,6 +544,7 @@ name_statement: NAME STR
sizeof(depth1_provname)) >=
sizeof(depth1_provname)) {
pjdlog_error("name argument is too long.");
+ free($2);
return (1);
}
break;
@@ -541,12 +556,14 @@ name_statement: NAME STR
sizeof(curres->hr_provname)) >=
sizeof(curres->hr_provname)) {
pjdlog_error("name argument is too long.");
+ free($2);
return (1);
}
break;
default:
assert(!"name at wrong depth level");
}
+ free($2);
}
;
@@ -558,6 +575,7 @@ local_statement: LOCAL STR
sizeof(depth1_localpath)) >=
sizeof(depth1_localpath)) {
pjdlog_error("local argument is too long.");
+ free($2);
return (1);
}
break;
@@ -569,12 +587,14 @@ local_statement: LOCAL STR
sizeof(curres->hr_localpath)) >=
sizeof(curres->hr_localpath)) {
pjdlog_error("local argument is too long.");
+ free($2);
return (1);
}
break;
default:
assert(!"local at wrong depth level");
}
+ free($2);
}
;
@@ -589,6 +609,7 @@ resource_node_start: STR
if (curres != NULL) {
switch (isitme($1)) {
case -1:
+ free($1);
return (1);
case 0:
break;
@@ -599,6 +620,7 @@ resource_node_start: STR
assert(!"invalid isitme() return value");
}
}
+ free($1);
}
;
@@ -624,8 +646,10 @@ remote_statement: REMOTE STR
sizeof(curres->hr_remoteaddr)) >=
sizeof(curres->hr_remoteaddr)) {
pjdlog_error("remote argument is too long.");
+ free($2);
return (1);
}
}
+ free($2);
}
;
diff --git a/sbin/hastd/primary.c b/sbin/hastd/primary.c
index aabbecf..5fb903c 100644
--- a/sbin/hastd/primary.c
+++ b/sbin/hastd/primary.c
@@ -646,6 +646,7 @@ init_remote(struct hast_resource *res, struct proto_conn **inp,
*/
(void)hast_activemap_flush(res);
}
+ nv_free(nvin);
pjdlog_info("Connected to %s.", res->hr_remoteaddr);
if (inp != NULL && outp != NULL) {
*inp = in;
diff --git a/sbin/hastd/synch.h b/sbin/hastd/synch.h
index 1dda49d..cf388d7 100644
--- a/sbin/hastd/synch.h
+++ b/sbin/hastd/synch.h
@@ -140,6 +140,8 @@ cv_init(pthread_cond_t *cv)
assert(error == 0);
error = pthread_cond_init(cv, &attr);
assert(error == 0);
+ error = pthread_condattr_destroy(&attr);
+ assert(error == 0);
}
static __inline void
cv_wait(pthread_cond_t *cv, pthread_mutex_t *lock)
OpenPOWER on IntegriCloud