[svn-commits] dvossel: branch 1.6.1 r201680 - in /branches/1.6.1: ./ apps/ channels/h323/ c...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 18 11:51:59 CDT 2009


Author: dvossel
Date: Thu Jun 18 11:51:54 2009
New Revision: 201680

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=201680
Log:
Merged revisions 201678 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r201678 | dvossel | 2009-06-18 11:37:42 -0500 (Thu, 18 Jun 2009) | 11 lines
  
  fixes some memory leaks and redundant conditions
  
  (closes issue #15269)
  Reported by: contactmayankjain
  Patches:
        patch.txt uploaded by contactmayankjain (license 740)
        memory_leak_stuff.trunk.diff uploaded by dvossel (license 671)
  Tested by: contactmayankjain, dvossel
........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/apps/app_rpt.c
    branches/1.6.1/channels/h323/ast_h323.cxx
    branches/1.6.1/channels/misdn/isdn_lib.c
    branches/1.6.1/channels/xpmr/xpmr.c
    branches/1.6.1/codecs/gsm/src/gsm_destroy.c
    branches/1.6.1/main/ast_expr2.c
    branches/1.6.1/main/ast_expr2f.c
    branches/1.6.1/main/asterisk.c
    branches/1.6.1/pbx/pbx_config.c
    branches/1.6.1/res/ael/ael_lex.c
    branches/1.6.1/res/res_config_ldap.c
    branches/1.6.1/utils/ael_main.c
    branches/1.6.1/utils/conf2ael.c
    branches/1.6.1/utils/extconf.c
    branches/1.6.1/utils/stereorize.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/apps/app_rpt.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/apps/app_rpt.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/apps/app_rpt.c (original)
+++ branches/1.6.1/apps/app_rpt.c Thu Jun 18 11:51:54 2009
@@ -3940,7 +3940,7 @@
 struct	rpt *myrpt;
 struct	rpt_link *l,*l1,linkbase;
 struct	ast_channel *mychannel;
-int id_malloc, vmajor, vminor, m;
+int vmajor, vminor, m;
 char *p,*ct,*ct_copy,*ident, *nodename,*cp;
 time_t t;
 #ifdef	NEW_ASTERISK
@@ -3987,14 +3987,10 @@
                 	ast_free(mytele);
                 	pthread_exit(NULL);
         	}
-		else{
-			id_malloc = 1;
-		}
 	}
 	else
 	{
 		ident = "";
-		id_malloc = 0;
 	}
 	rpt_mutex_unlock(&myrpt->lock);
 		
@@ -4010,8 +4006,7 @@
 		ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
 		rpt_mutex_unlock(&myrpt->lock);
 		ast_free(nodename);
-		if(id_malloc)
-			ast_free(ident);
+		ast_free(ident);
 		ast_free(mytele);		
 		pthread_exit(NULL);
 	}
@@ -4057,8 +4052,7 @@
 		rpt_mutex_unlock(&myrpt->lock);
 		ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
 		ast_free(nodename);
-		if(id_malloc)
-			ast_free(ident);
+		ast_free(ident);
 		ast_free(mytele);		
 		ast_hangup(mychannel);
 		pthread_exit(NULL);
@@ -4252,8 +4246,7 @@
 				rpt_mutex_unlock(&myrpt->lock);
 				ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
 				ast_free(nodename);
-				if(id_malloc)
-					ast_free(ident);
+				ast_free(ident);
 				ast_free(mytele);		
 				ast_hangup(mychannel);
 				pthread_exit(NULL);
@@ -4293,8 +4286,7 @@
 				rpt_mutex_unlock(&myrpt->lock);
 				ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
 				ast_free(nodename);
-				if(id_malloc)
-					ast_free(ident);
+				ast_free(ident);
 				ast_free(mytele);		
 				ast_hangup(mychannel);
 				pthread_exit(NULL);
@@ -4816,8 +4808,7 @@
 				rpt_mutex_unlock(&myrpt->lock);
 				ast_log(LOG_NOTICE,"Telemetry thread aborted at line %d, mode: %d\n",__LINE__, mytele->mode); /*@@@@@@@@@@@*/
 				ast_free(nodename);
-				if(id_malloc)
-					ast_free(ident);
+				ast_free(ident);
 				ast_free(mytele);		
 				ast_hangup(mychannel);
 				pthread_exit(NULL);
@@ -5193,8 +5184,7 @@
 	myrpt->active_telem = NULL;
 	rpt_mutex_unlock(&myrpt->lock);
 	ast_free(nodename);
-	if(id_malloc)
-		ast_free(ident);
+	ast_free(ident);
 	ast_free(mytele);		
 	ast_hangup(mychannel);
 #ifdef  APP_RPT_LOCK_DEBUG

Modified: branches/1.6.1/channels/h323/ast_h323.cxx
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/channels/h323/ast_h323.cxx?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/channels/h323/ast_h323.cxx (original)
+++ branches/1.6.1/channels/h323/ast_h323.cxx Thu Jun 18 11:51:54 2009
@@ -571,8 +571,7 @@
 {
 #ifdef H323_H450
 	/* Dispatcher will free out all registered handlers */
-	if (h450dispatcher)
-		delete h450dispatcher;
+	delete h450dispatcher;
 	h450dispatcher = new H450xDispatcher(*this);
 	h4502handler = new H4502Handler(*this, *h450dispatcher);
 	h4504handler = new MyH4504Handler(*this, *h450dispatcher);
@@ -1987,8 +1986,9 @@
 	if (cap && cap->IsUsable(*this)) {
 		lastcap++;
 		lastcap = localCapabilities.SetCapability(0, lastcap, cap);
-	} else if (cap)
+	} else {
 		delete cap;				/* Capability is not usable */
+	}
 
 	dtmfMode = dtmf_mode;
 	if (h323debug) {
@@ -2000,8 +2000,9 @@
 			cap = new H323_UserInputCapability(H323_UserInputCapability::BasicString);
 			if (cap && cap->IsUsable(*this)) {
 				lastcap = localCapabilities.SetCapability(0, lastcap, cap);
-			} else if (cap)
+			} else {
 				delete cap;		/* Capability is not usable */
+			}	
 			sendUserInputMode = SendUserInputAsString;
 		} else {
 			if ((dtmfMode & H323_DTMF_RFC2833) != 0) {
@@ -2010,8 +2011,7 @@
 					lastcap = localCapabilities.SetCapability(0, lastcap, cap);
 				else {
 					dtmfMode |= H323_DTMF_SIGNAL;
-					if (cap)
-						delete cap;	/* Capability is not usable */
+					delete cap;	/* Capability is not usable */
 				}
 			}
 			if ((dtmfMode & H323_DTMF_CISCO) != 0) {
@@ -2023,8 +2023,7 @@
 					dtmfMode |= H323_DTMF_SIGNAL;
 				} else {
 					dtmfMode |= H323_DTMF_SIGNAL;
-					if (cap)
-						delete cap;	/* Capability is not usable */
+					delete cap;	/* Capability is not usable */
 				}
 			}
 			if ((dtmfMode & H323_DTMF_SIGNAL) != 0) {
@@ -2032,7 +2031,7 @@
 				cap = new H323_UserInputCapability(H323_UserInputCapability::SignalToneH245);
 				if (cap && cap->IsUsable(*this))
 					lastcap = localCapabilities.SetCapability(0, lastcap, cap);
-				else if (cap)
+				else
 					delete cap;	/* Capability is not usable */
 			}
 			sendUserInputMode = SendUserInputAsTone;	/* RFC2833 transmission handled at Asterisk level */

Modified: branches/1.6.1/channels/misdn/isdn_lib.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/channels/misdn/isdn_lib.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/channels/misdn/isdn_lib.c (original)
+++ branches/1.6.1/channels/misdn/isdn_lib.c Thu Jun 18 11:51:54 2009
@@ -2231,6 +2231,10 @@
 
 	if (!rx || !tx) {
 		cb_log(0,0,"Couldn't open files: %s\n",strerror(errno));
+		if (rx)
+			fclose(rx);
+		if (tx)
+			fclose(tx);
 		return ;
 	}
 	

Modified: branches/1.6.1/channels/xpmr/xpmr.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/channels/xpmr/xpmr.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/channels/xpmr/xpmr.c (original)
+++ branches/1.6.1/channels/xpmr/xpmr.c Thu Jun 18 11:51:54 2009
@@ -157,7 +157,7 @@
 	TRACEJ(2,(" source len = %i\n",slen));
 
 	pd=*dest;
-	if(pd) free(pd);
+	free(pd);
     pd=calloc(slen+1,1);
 	memcpy(pd,src,slen);
 	*dest=pd;

Modified: branches/1.6.1/codecs/gsm/src/gsm_destroy.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/codecs/gsm/src/gsm_destroy.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/codecs/gsm/src/gsm_destroy.c (original)
+++ branches/1.6.1/codecs/gsm/src/gsm_destroy.c Thu Jun 18 11:51:54 2009
@@ -22,5 +22,5 @@
 
 void gsm_destroy P1((S), gsm S)
 {
-	if (S) free((char *)S);
+	free((char *)S);
 }

Modified: branches/1.6.1/main/ast_expr2.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/main/ast_expr2.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/main/ast_expr2.c (original)
+++ branches/1.6.1/main/ast_expr2.c Thu Jun 18 11:51:54 2009
@@ -2415,6 +2415,7 @@
 free_value (struct val *vp)
 {	
 	if (vp==NULL) {
+		free(vp);
 		return;
 	}
 	if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)

Modified: branches/1.6.1/main/ast_expr2f.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/main/ast_expr2f.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/main/ast_expr2f.c (original)
+++ branches/1.6.1/main/ast_expr2f.c Thu Jun 18 11:51:54 2009
@@ -2379,7 +2379,7 @@
 
 void ast_yyfree(void *ptr, yyscan_t yyscanner)
 {
-      if (ptr) /* the normal generated ast_yyfree func just frees its first arg;
+       /* the normal generated ast_yyfree func just frees its first arg;
                     this get complaints on some systems, as sometimes this
                     arg is a nil ptr! It's usually not fatal, but is irritating! */
               free( (char *) ptr );
@@ -2423,8 +2423,7 @@
 			else
 				buf[0] = 0;
 			return_value = strlen(buf);
-			if (io.val->u.s)
-				free(io.val->u.s);
+			free(io.val->u.s);
 		}
 		free(io.val);
 	}

Modified: branches/1.6.1/main/asterisk.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/main/asterisk.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/main/asterisk.c (original)
+++ branches/1.6.1/main/asterisk.c Thu Jun 18 11:51:54 2009
@@ -802,8 +802,7 @@
 	AST_RWLIST_TRAVERSE_SAFE_END;
 	AST_RWLIST_UNLOCK(&atexits);
 
-	if (ae)
-		free(ae);
+	free(ae);
 }
 
 /* Sending commands from consoles back to the daemon requires a terminating NULL */

Modified: branches/1.6.1/pbx/pbx_config.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/pbx/pbx_config.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/pbx/pbx_config.c (original)
+++ branches/1.6.1/pbx/pbx_config.c Thu Jun 18 11:51:54 2009
@@ -451,8 +451,7 @@
 
 		ast_unlock_contexts();
 	error2:
-		if (exten)
-			free(exten);
+		free(exten);
 	} else if (a->pos == 4) { /* 'dialplan remove extension EXT _X_' (priority) */
 		char *exten = NULL, *context, *cid, *p;
 		struct ast_context *c;
@@ -509,8 +508,7 @@
 		}
 		ast_unlock_contexts();
 	error3:
-		if (exten)
-			free(exten);
+		free(exten);
 	}
 	return ret; 
 }
@@ -1139,8 +1137,7 @@
 				ret = strdup(ast_get_context_name(c));
 		}
 
-		if (ignorepat)
-			free(ignorepat);
+		free(ignorepat);
 		ast_unlock_contexts();
 		return ret;
 	}

Modified: branches/1.6.1/res/ael/ael_lex.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/res/ael/ael_lex.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/res/ael/ael_lex.c (original)
+++ branches/1.6.1/res/ael/ael_lex.c Thu Jun 18 11:51:54 2009
@@ -3221,8 +3221,7 @@
 
 void ael_yyfree(void *ptr, yyscan_t yyscanner)
 {
-	if (ptr)
-		free( (char*) ptr );
+	free( (char*) ptr );
 }
 
 static int pbcpop(char x)
@@ -3361,8 +3360,7 @@
 		*errors = 1;
 		return 0;
 	}
-	if (my_file)
-		free(my_file);
+	free(my_file);
 	my_file = strdup(filename);
 	stat(filename, &stats);
 	buffer = (char*)malloc(stats.st_size+2);

Modified: branches/1.6.1/res/res_config_ldap.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/res/res_config_ldap.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/res/res_config_ldap.c (original)
+++ branches/1.6.1/res/res_config_ldap.c Thu Jun 18 11:51:54 2009
@@ -871,12 +871,8 @@
 		}
 	}
 
-	if (filter)
-		ast_free(filter);
-
-	if (clean_basedn)
-		ast_free(clean_basedn);
-
+	ast_free(filter);
+	ast_free(clean_basedn);
 	ast_mutex_unlock(&ldap_lock);
 
 	return vars;
@@ -1270,10 +1266,8 @@
 			ldap_err2string(result));
 
 		ast_mutex_unlock(&ldap_lock);
-		if (filter)
-			free(filter);
-		if (clean_basedn)
-			free(clean_basedn);
+		free(filter);
+		free(clean_basedn);
 		ldap_msgfree(ldap_result_msg);
 		ldap_mods_free(ldap_mods, 0);
 		return -1;
@@ -1296,10 +1290,8 @@
 	}
 
 	ast_mutex_unlock(&ldap_lock);
-	if (filter)
-		free(filter);
-	if (clean_basedn)
-		free(clean_basedn);
+	free(filter);
+	free(clean_basedn);
 	ldap_msgfree(ldap_result_msg);
 	ldap_mods_free(ldap_mods, 0);
 	return num_entries;

Modified: branches/1.6.1/utils/ael_main.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/utils/ael_main.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/utils/ael_main.c (original)
+++ branches/1.6.1/utils/ael_main.c Thu Jun 18 11:51:54 2009
@@ -299,8 +299,7 @@
 	}
 	
 	/* since add_extension2 is responsible for the malloc'd data stuff */
-	if( data )
-		free(data);
+	free(data);
 	return 0;
 }
 

Modified: branches/1.6.1/utils/conf2ael.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/utils/conf2ael.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/utils/conf2ael.c (original)
+++ branches/1.6.1/utils/conf2ael.c Thu Jun 18 11:51:54 2009
@@ -471,7 +471,7 @@
 								if (mon) {
 									*mon++ = 0;
 									/* now all 4 fields are set; what do we do? */
-									pvalIncludesAddIncludeWithTimeConstraints(incl, all, hr, dow, dom, mon);
+									pvalIncludesAddIncludeWithTimeConstraints(incl, strdup(all), strdup(hr), strdup(dow), strdup(dom), strdup(mon));
 									/* the original data is always best to keep (no 2-min rounding) */
 								} else {
 									ast_log(LOG_ERROR,"No month spec attached to include!\n");
@@ -483,6 +483,7 @@
 							ast_log(LOG_ERROR,"No day of week spec attached to include!\n");
 						}
 					}
+					free(all);
 				}
 				tmpi = tmpi->next;
 			}

Modified: branches/1.6.1/utils/extconf.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/utils/extconf.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/utils/extconf.c (original)
+++ branches/1.6.1/utils/extconf.c Thu Jun 18 11:51:54 2009
@@ -2993,8 +2993,7 @@
 	
 static void ast_var_delete(struct ast_var_t *var)
 {
-	if (var)
-		free(var);
+	free(var);
 }
 
 

Modified: branches/1.6.1/utils/stereorize.c
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.6.1/utils/stereorize.c?view=diff&rev=201680&r1=201679&r2=201680
==============================================================================
--- branches/1.6.1/utils/stereorize.c (original)
+++ branches/1.6.1/utils/stereorize.c Thu Jun 18 11:51:54 2009
@@ -156,4 +156,7 @@
       }
    }
    /* That was an endless loop. This point is never reached. */
+   free(leftsample);
+   free(rightsample);
+   free(stereosample);
 }




More information about the svn-commits mailing list