# Better clean-up in some cases of errors. --- trunk.orig/channels/chan_zap.c +++ trunk/channels/chan_zap.c @@ -14087,10 +14087,13 @@ static int setup_zap(int reload) v = ast_variable_browse(cfg, "channels"); res = process_zap(&base_conf, v, reload, 0); - ast_mutex_unlock(&iflock); ast_config_destroy(cfg); - if (res) + if (res) { + ast_mutex_unlock(&iflock); + if (ucfg) + ast_config_destroy(cfg); return res; + } if (ucfg) { char *cat; const char *chans; @@ -14103,13 +14106,21 @@ static int setup_zap(int reload) if (memcpy(&conf, &base_conf, sizeof(conf)) == NULL) { ast_log(LOG_ERROR, "Not enough memory for conf copy\n"); ast_config_destroy(ucfg); + ast_mutex_unlock(&iflock); return -1; } - process_zap(&conf, ast_variable_browse(ucfg, cat), reload, 0); + + res = process_zap(&conf, ast_variable_browse(ucfg, cat), reload, 0); + if (res) { + ast_config_destroy(ucfg); + ast_mutex_unlock(&iflock); + return res; + } } } ast_config_destroy(ucfg); } + ast_mutex_unlock(&iflock); #ifdef HAVE_PRI if (!reload) { int x;