Some memleak fixes.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 4 Feb 2009 15:13:46 +0000 (15:13 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 4 Feb 2009 15:13:46 +0000 (15:13 +0000)
org.glite.security.gss/src/glite_gss.c
org.glite.security.gss/test/test_gss.cpp

index a62e2e7..226b38f 100644 (file)
@@ -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);
index 28739c2..4fa2845 100644 (file)
@@ -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()
 {