From 2a73f2d58cd29c6ecaade828db6ce1f5dde18a0e Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 21 Feb 2017 15:58:29 +0100 Subject: lib: Clean up memory management in cacep policies --- src/lib/pol/cacep_anonymous_auth.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/lib/pol/cacep_anonymous_auth.c') diff --git a/src/lib/pol/cacep_anonymous_auth.c b/src/lib/pol/cacep_anonymous_auth.c index 1ad8a533..1fcc730a 100644 --- a/src/lib/pol/cacep_anonymous_auth.c +++ b/src/lib/pol/cacep_anonymous_auth.c @@ -52,6 +52,8 @@ static struct cacep_info * anonymous_info(void) if (info == NULL) return NULL; + cacep_info_init(info); + info->name = malloc(NAME_LEN + 1); if (info->name == NULL) { free(info); @@ -151,6 +153,8 @@ struct cacep_info * cacep_anonymous_auth(int fd, { struct cacep_info * tmp; + assert(info); + if (send_msg(fd, info)) return NULL; @@ -161,6 +165,7 @@ struct cacep_info * cacep_anonymous_auth(int fd, if (strcmp(info->proto.protocol, tmp->proto.protocol) || info->proto.pref_version != tmp->proto.pref_version || info->proto.pref_syntax != tmp->proto.pref_syntax) { + cacep_info_fini(tmp); free(tmp); return NULL; } @@ -176,11 +181,14 @@ struct cacep_info * cacep_anonymous_auth_wait(int fd, { struct cacep_info * tmp; + assert(info); + tmp = read_msg(fd); if (tmp == NULL) return NULL; if (send_msg(fd, info)) { + cacep_info_fini(tmp); free(tmp); return NULL; } @@ -188,11 +196,10 @@ struct cacep_info * cacep_anonymous_auth_wait(int fd, if (strcmp(info->proto.protocol, tmp->proto.protocol) || info->proto.pref_version != tmp->proto.pref_version || info->proto.pref_syntax != tmp->proto.pref_syntax) { + cacep_info_fini(tmp); free(tmp); return NULL; } - tmp->data = NULL; - return tmp; } -- cgit v1.2.3