imv-attestation: Fix memory leaks when creating functional components
authorTobias Brunner <tobias@strongswan.org>
Fri, 11 Dec 2015 14:18:38 +0000 (15:18 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 11 Dec 2015 14:18:38 +0000 (15:18 +0100)
src/libimcv/plugins/imv_attestation/imv_attestation_agent.c
src/libimcv/plugins/imv_attestation/imv_attestation_state.h
src/libimcv/pts/components/pts_component_manager.h

index 28ebd00..91c12f3 100644 (file)
@@ -603,8 +603,8 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
                                                        if (!comp)
                                                        {
                                                                comp_name->log(comp_name, "unregistered ");
-                                                               comp_name->destroy(comp_name);
                                                        }
+                                                       comp_name->destroy(comp_name);
                                                }
 
                                                /* do TPM IMA measurements */
@@ -620,8 +620,8 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
                                                        if (!comp)
                                                        {
                                                                comp_name->log(comp_name, "unregistered ");
-                                                               comp_name->destroy(comp_name);
                                                        }
+                                                       comp_name->destroy(comp_name);
                                                }
 
                                                /* do TPM TRUSTED BOOT measurements */
@@ -637,8 +637,8 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
                                                        if (!comp)
                                                        {
                                                                comp_name->log(comp_name, "unregistered ");
-                                                               comp_name->destroy(comp_name);
                                                        }
+                                                       comp_name->destroy(comp_name);
                                                }
                                                attestation_state->set_handshake_state(attestation_state,
                                                                                        IMV_ATTESTATION_STATE_NONCE_REQ);
index 39a8eee..d9bb47c 100644 (file)
@@ -115,7 +115,7 @@ struct imv_attestation_state_t {
        /**
         * Create and add an entry to the list of Functional Components
         *
-        * @param name                          Component Functional Name
+        * @param name                          Component Functional Name (cloned)
         * @param depth                         Sub-component Depth
         * @param pts_db                        PTS measurement database
         * @return                                      created functional component instance or NULL
index 61055ec..00f8765 100644 (file)
@@ -45,7 +45,7 @@ struct pts_component_manager_t {
         * @param comp_func_names               Vendor-specific Component Functional names
         * @param qualifier_type_size   Vendor-specific Qualifier Type size
         * @param qualifier_flag_names  Vendor-specific Qualifier Flag names
-        * @param qualifier_type_names  Vendor-specific Qualifier Type names 
+        * @param qualifier_type_names  Vendor-specific Qualifier Type names
         */
        void (*add_vendor)(pts_component_manager_t *this, pen_t vendor_id,
                                           enum_name_t *comp_func_names,
@@ -106,7 +106,7 @@ struct pts_component_manager_t {
         * @param pts_db                                PTS measurement database
         * @return                                              Component object if supported, NULL else
         */
-       pts_component_t* (*create)(pts_component_manager_t *this, 
+       pts_component_t* (*create)(pts_component_manager_t *this,
                                                           pts_comp_func_name_t *name, u_int32_t depth,
                                                           pts_database_t *pts_db);