]> sjero.net Git - linphone/commitdiff
Fix memory leaks in linphonecore
authorPierre-Eric Pelloux-Prayer <pelloux@gmail.com>
Wed, 8 Feb 2012 09:36:52 +0000 (10:36 +0100)
committerPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@linphone.org>
Wed, 8 Feb 2012 16:40:22 +0000 (17:40 +0100)
coreapi/linphonecore.c
coreapi/proxy.c

index 0b200a42b66c9ded7e73d41a9bf09e074831012f..ebdb615de46e78573c0202f5efe018af89a5004b 100644 (file)
@@ -1632,6 +1632,7 @@ static void monitor_network_state(LinphoneCore *lc, time_t curtime){
 static void proxy_update(LinphoneCore *lc){
        ms_list_for_each(lc->sip_conf.proxies,(void (*)(void*))&linphone_proxy_config_update);
        MSList* list=ms_list_copy(lc->sip_conf.deleted_proxies);
+       MSList* copy=list;
        for(;list!=NULL;list=list->next){
                LinphoneProxyConfig* cfg = (LinphoneProxyConfig*) list->data;
                if (ms_time(NULL) - cfg->deletion_date > 5) {
@@ -1640,7 +1641,7 @@ static void proxy_update(LinphoneCore *lc){
                        linphone_proxy_config_destroy(cfg);
                }
        }
-       ms_list_free(list);
+       ms_list_free(copy);
 }
 
 static void assign_buddy_info(LinphoneCore *lc, BuddyInfo *info){
index d1ef5355bdb5579faac920f4bdb836db23a97f9d..6dc52e3c8178ec0ed833d30b80b9a918127ae13d 100644 (file)
@@ -514,8 +514,12 @@ struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig
  * This will start registration on the proxy, if registration is enabled.
 **/
 int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cfg){
-       if (!linphone_proxy_config_check(lc,cfg)) return -1;
+       if (!linphone_proxy_config_check(lc,cfg)) {
+               linphone_proxy_config_destroy(cfg);
+               return -1;
+       }
        if (ms_list_find(lc->sip_conf.proxies,cfg)!=NULL){
+               linphone_proxy_config_destroy(cfg);
                ms_warning("ProxyConfig already entered, ignored.");
                return 0;
        }
@@ -549,10 +553,11 @@ void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cf
 **/
 void linphone_core_clear_proxy_config(LinphoneCore *lc){
        MSList* list=ms_list_copy(linphone_core_get_proxy_config_list((const LinphoneCore*)lc));
+       MSList* copy=list;
        for(;list!=NULL;list=list->next){
                linphone_core_remove_proxy_config(lc,(LinphoneProxyConfig *)list->data);
        }
-       ms_list_free(list);
+       ms_list_free(copy);
        linphone_proxy_config_write_all_to_config_file(lc);
 }
 /**