[svn-commits] tilghman: trunk r164168 - /trunk/include/asterisk/strings.h

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Dec 14 12:16:28 CST 2008


Author: tilghman
Date: Sun Dec 14 12:16:28 2008
New Revision: 164168

URL: http://svn.digium.com/view/asterisk?view=rev&rev=164168
Log:
Don't pass a negative to an unsigned type and expect things to work correctly.

Modified:
    trunk/include/asterisk/strings.h

Modified: trunk/include/asterisk/strings.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/strings.h?view=diff&rev=164168&r1=164167&r2=164168
==============================================================================
--- trunk/include/asterisk/strings.h (original)
+++ trunk/include/asterisk/strings.h Sun Dec 14 12:16:28 2008
@@ -477,11 +477,11 @@
 )
 
 AST_INLINE_API(
-char *ast_str_truncate(struct ast_str *buf, size_t len),
+char *ast_str_truncate(struct ast_str *buf, ssize_t len),
 {
 #ifdef DEBUG_OPAQUE
 	if (len < 0) {
-		buf->used2 += len;
+		buf->used2 += (ssize_t) abs(len) > buf->used2 ? -buf->used2 : len;
 	} else {
 		buf->used2 = len;
 	}
@@ -489,7 +489,7 @@
 	return buf->str2;
 #else
 	if (len < 0) {
-		buf->used += len;
+		buf->used += (ssize_t) abs(len) > buf->used ? -buf->used : len;
 	} else {
 		buf->used = len;
 	}




More information about the svn-commits mailing list