[Asterisk-cvs] asterisk utils.c,1.49,1.50

kpfleming at lists.digium.com kpfleming at lists.digium.com
Fri Jun 17 10:26:42 CDT 2005


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv31683

Modified Files:
	utils.c 
Log Message:
don't let ast_trim_blanks operate on empty strings or run off the beginning of the string


Index: utils.c
===================================================================
RCS file: /usr/cvsroot/asterisk/utils.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- utils.c	17 Jun 2005 13:25:00 -0000	1.49
+++ utils.c	17 Jun 2005 14:27:57 -0000	1.50
@@ -46,13 +46,15 @@
  
 char *ast_trim_blanks(char *str)
 {
-	if (str) {
-		str += strlen(str) - 1;
-		while (*str && *str < 33)
-			str--;
-		*(++str) = '\0'; /* terminate string */
+	char *work = str;
+
+	if (work && !ast_strlen_zero(work)) {
+		work += strlen(work) - 1;
+		while ((work >= str) && *work && *work < 33)
+			work--;
+		*(++work) = '\0'; /* terminate string */
 	}
-	return str;
+	return work;
 }
 
 char *ast_skip_nonblanks(char *str)




More information about the svn-commits mailing list