]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
- fixed some memleaks/freebugs
authorMartin Willi <martin@strongswan.org>
Wed, 31 May 2006 14:13:26 +0000 (14:13 -0000)
committerMartin Willi <martin@strongswan.org>
Wed, 31 May 2006 14:13:26 +0000 (14:13 -0000)
- leak detective works almost usable now (?!)

src/charon/config/policies/policy.c
src/charon/network/socket.c
src/charon/sa/authenticator.c

index 14ca5036596536a3a7572fbcaa5485e2dd8a68db..94a6dea83259bc2e1fc3360e90198bf897161ade 100644 (file)
@@ -330,7 +330,6 @@ static policy_t *clone(private_policy_t *this)
        }
        iterator->destroy(iterator);
        
-       clone->name = strdup(this->name);
        return &clone->public;
 }
 
index 89f67c96489f436be64aadee890d6386e3862da2..ba01702cb734146b517997e93ed29e84f703c3dd 100644 (file)
@@ -137,7 +137,7 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
 {
        char buffer[MAX_PACKET];
        chunk_t data;
-       packet_t *pkt = packet_create();
+       packet_t *pkt;
        host_t *source, *dest;
        int bytes_read = 0;
        
@@ -164,16 +164,12 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                }
                iterator->destroy(iterator);
                
-               /* add packet destroy handler for cancellation, enable cancellation */
-               pthread_cleanup_push((void(*)(void*))pkt->destroy, (void*)pkt);
-               pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
-               
                this->logger->log(this->logger, CONTROL|LEVEL1, "waiting on sockets");
-               bytes_read = select(max_fd, &readfds, NULL, NULL, NULL);
                
-               /* reset cancellation, remove packet destroy handler (without executing) */
+               /* allow cancellation while select()-ing */
+               pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
+               bytes_read = select(max_fd, &readfds, NULL, NULL, NULL);
                pthread_setcancelstate(oldstate, NULL);
-               pthread_cleanup_pop(0);
                
                /* read on the first nonblocking socket */
                bytes_read = 0;
@@ -204,6 +200,7 @@ static status_t receiver(private_socket_t *this, packet_t **packet)
                        u_int16_t dest_port = ntohs(*(u_int16_t*)(buffer + 22));
                        source = host_create_from_chunk(AF_INET, source_chunk, source_port);
                        dest = host_create_from_chunk(AF_INET, dest_chunk, dest_port);
+                       pkt = packet_create();
                        pkt->set_source(pkt, source);
                        pkt->set_destination(pkt, dest);
                        break;
index 52bd256f3a4123b25a28e11ceb6430b35f2ba272..81dee0b0da0ce348a91d5fc650b984188b6ebc2e 100644 (file)
@@ -356,6 +356,7 @@ static status_t compute_auth_data (private_authenticator_t *this,
                        this->logger->log(this->logger, CONTROL, "looking for private key with keyid %s", buf);
 
                        my_key = charon->credentials->get_rsa_private_key(charon->credentials, my_pubkey);
+                       my_pubkey->destroy(my_pubkey);
                        if (my_key == NULL)
                        {
                                char buf[BUF_LEN];