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
This commit is contained in:
Tilghman Lesher
2008-12-14 18:16:28 +00:00
parent c0fc8edbbd
commit c31cbd7f1a

View File

@@ -477,11 +477,11 @@ attribute_pure char *ast_str_buffer(struct ast_str *buf),
) )
AST_INLINE_API( 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 #ifdef DEBUG_OPAQUE
if (len < 0) { if (len < 0) {
buf->used2 += len; buf->used2 += (ssize_t) abs(len) > buf->used2 ? -buf->used2 : len;
} else { } else {
buf->used2 = len; buf->used2 = len;
} }
@@ -489,7 +489,7 @@ char *ast_str_truncate(struct ast_str *buf, size_t len),
return buf->str2; return buf->str2;
#else #else
if (len < 0) { if (len < 0) {
buf->used += len; buf->used += (ssize_t) abs(len) > buf->used ? -buf->used : len;
} else { } else {
buf->used = len; buf->used = len;
} }