From 4aa5d58caf8a23bb04d2e8fde326b61fa700e8e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Wed, 4 Feb 2009 15:13:46 +0000 Subject: [PATCH] Some memleak fixes. --- org.glite.security.gss/src/glite_gss.c | 12 +++++++----- org.glite.security.gss/test/test_gss.cpp | 7 +++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/org.glite.security.gss/src/glite_gss.c b/org.glite.security.gss/src/glite_gss.c index a62e2e7..226b38f 100644 --- a/org.glite.security.gss/src/glite_gss.c +++ b/org.glite.security.gss/src/glite_gss.c @@ -170,8 +170,8 @@ static int asyn_gethostbyname(char **addrOut, char const *name, struct timeval * if (ar.err == NETDB_SUCCESS) { *addrOut = malloc(sizeof(struct in_addr)); memcpy(*addrOut,ar.ent->h_addr_list[0], sizeof(struct in_addr)); - free_hostent(ar.ent); } + free_hostent(ar.ent); return(ar.err); } @@ -374,14 +374,16 @@ recv_token(int sock, void **token, size_t *token_length, struct timeval *to) } if (count==0) { - if (tl==0) + if (tl==0) { + free(t); return EDG_WLL_GSS_ERROR_EOF; - else goto end; + } else goto end; } tmp=realloc(t, tl + count); if (tmp == NULL) { - errno = ENOMEM; - return EDG_WLL_GSS_ERROR_ERRNO; + errno = ENOMEM; + free(t); + return EDG_WLL_GSS_ERROR_ERRNO; } t = tmp; memcpy(t + tl, buf, count); diff --git a/org.glite.security.gss/test/test_gss.cpp b/org.glite.security.gss/test/test_gss.cpp index 28739c2..4fa2845 100644 --- a/org.glite.security.gss/test/test_gss.cpp +++ b/org.glite.security.gss/test/test_gss.cpp @@ -31,6 +31,7 @@ public: void errorTest(); void setUp(); + void tearDown(); private: edg_wll_GssCred my_cred; @@ -59,6 +60,8 @@ void GSSTest::replier() { if ( edg_wll_gss_write(&conn, buf, len, &timeout, &stat) ) exit(1); } + edg_wll_gss_close(&conn, &timeout); + exit(0); } @@ -104,6 +107,10 @@ void GSSTest::setUp(void) { } +void GSSTest::tearDown(void) { + edg_wll_gss_release_cred(&my_cred, NULL); +} + void GSSTest::echo() { -- 1.8.2.3