diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/fitz/buffer.c | 6 | ||||
-rw-r--r-- | source/fitz/output.c | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/source/fitz/buffer.c b/source/fitz/buffer.c index 26d0afea..86947df0 100644 --- a/source/fitz/buffer.c +++ b/source/fitz/buffer.c @@ -236,9 +236,9 @@ fz_buffer_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list o len = fz_vsnprintf((char *)buffer->data + buffer->len, slack, fmt, args); va_copy_end(args); - /* len = number of chars written, not including the terminating - * NULL, so len+1 > slack means "truncated". */ - if (len+1 > slack) + /* len is the number of characters in the formatted string (not including + * the terminating zero), so if (len > slack) the string was truncated. */ + if (len > slack) { /* Grow the buffer and retry */ fz_ensure_buffer(ctx, buffer, buffer->len + len); diff --git a/source/fitz/output.c b/source/fitz/output.c index 1f713709..b3efb121 100644 --- a/source/fitz/output.c +++ b/source/fitz/output.c @@ -162,11 +162,11 @@ fz_vprintf(fz_context *ctx, fz_output *out, const char *fmt, va_list old_args) va_copy_end(args); /* If that failed, allocate a big enough buffer */ - if (len >= sizeof buffer) + if (len > sizeof buffer) { - p = fz_malloc(ctx, len + 1); + p = fz_malloc(ctx, len); va_copy(args, old_args); - fz_vsnprintf(p, len + 1, fmt, args); + fz_vsnprintf(p, len, fmt, args); va_copy_end(args); } |