[asterisk-commits] tilghman: trunk r177287 - /trunk/main/strings.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 18 17:51:35 CST 2009


Author: tilghman
Date: Wed Feb 18 17:51:35 2009
New Revision: 177287

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=177287
Log:
Handle negative length and eliminate a condition that is always true.

Modified:
    trunk/main/strings.c

Modified: trunk/main/strings.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/main/strings.c?view=diff&rev=177287&r1=177286&r2=177287
==============================================================================
--- trunk/main/strings.c (original)
+++ trunk/main/strings.c Wed Feb 18 17:51:35 2009
@@ -114,8 +114,10 @@
 	int dynamic = 0;
 	char *ptr = append ? &((*buf)->__AST_STR_STR[(*buf)->__AST_STR_USED]) : (*buf)->__AST_STR_STR;
 
-	if (!maxlen) {
-		dynamic = 1;
+	if (maxlen < 1) {
+		if (maxlen == 0) {
+			dynamic = 1;
+		}
 		maxlen = (*buf)->__AST_STR_LEN;
 	}
 
@@ -140,10 +142,7 @@
 			/* What we extended the buffer by */
 			maxlen = old;
 
-			/* Update ptr, if necessary */
-			if ((*buf)->__AST_STR_STR != oldbase) {
-				ptr = ptr - oldbase + (*buf)->__AST_STR_STR;
-			}
+			ptr += (*buf)->__AST_STR_STR - oldbase;
 		}
 	}
 	if (__builtin_expect(!(maxsrc && maxlen), 0)) {




More information about the asterisk-commits mailing list