From: Tilghman Lesher Date: Sun, 14 Dec 2008 18:16:28 +0000 (+0000) Subject: Don't pass a negative to an unsigned type and expect things to work correctly. X-Git-Tag: 1.6.2.0-beta1~621 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c31cbd7f1a8ea2978b902c32c19607f24516f22b;p=thirdparty%2Fasterisk.git Don't pass a negative to an unsigned type and expect things to work correctly. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@164168 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h index 84782a3acd..0acc834368 100644 --- a/include/asterisk/strings.h +++ b/include/asterisk/strings.h @@ -477,11 +477,11 @@ attribute_pure char *ast_str_buffer(struct ast_str *buf), ) 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 @@ char *ast_str_truncate(struct ast_str *buf, size_t len), 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; }