]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
ike-cfg: Allow passing NULL to add_proposal()
authorMartin Willi <martin@revosec.ch>
Thu, 24 Apr 2014 12:19:12 +0000 (14:19 +0200)
committerMartin Willi <martin@revosec.ch>
Fri, 16 May 2014 14:01:21 +0000 (16:01 +0200)
This simplifies adding default proposals with constructors potentially
returning NULL.

src/libcharon/config/ike_cfg.c
src/libcharon/config/ike_cfg.h

index e08bb3f679d27f9a1d86958aed57cbe9bf2c4d96..42a3e90577c82e9124d5b6fd395621cf9d5d9de4 100644 (file)
@@ -281,7 +281,10 @@ METHOD(ike_cfg_t, get_dscp, u_int8_t,
 METHOD(ike_cfg_t, add_proposal, void,
        private_ike_cfg_t *this, proposal_t *proposal)
 {
-       this->proposals->insert_last(this->proposals, proposal);
+       if (proposal)
+       {
+               this->proposals->insert_last(this->proposals, proposal);
+       }
 }
 
 METHOD(ike_cfg_t, get_proposals, linked_list_t*,
index f9e4fbebc258479e70efd01952be87882474010d..adfcabf700767f13ece5f999f8561a6da0d149ef 100644 (file)
@@ -148,9 +148,10 @@ struct ike_cfg_t {
         * Adds a proposal to the list.
         *
         * The first added proposal has the highest priority, the last
-        * added the lowest.
+        * added the lowest. It is safe to add NULL as proposal, which has no
+        * effect.
         *
-        * @param proposal              proposal to add
+        * @param proposal              proposal to add, or NULL
         */
        void (*add_proposal) (ike_cfg_t *this, proposal_t *proposal);