diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-01-04 12:17:39 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-01-05 14:47:37 +0100 |
commit | ef4897ce4c3c497179ff666745a75349600bf5f6 (patch) | |
tree | f2bc36fcec9975afcebc45ce4956ff2c5b669160 /source/fitz/buffer.c | |
parent | d5394cbcf3a98dcabc49264172d4ce6618535d91 (diff) | |
download | mupdf-ef4897ce4c3c497179ff666745a75349600bf5f6.tar.xz |
Clarify snprintf length when printing to fz_buffer and fz_output.
The +1's for zero terminating bytes are not needed: printf to a fz_buffer
or fz_output does not write a zero terminator. The extra code to add
space for a zero terminator when calling snprintf internally are
merely confusing.
Diffstat (limited to 'source/fitz/buffer.c')
-rw-r--r-- | source/fitz/buffer.c | 6 |
1 files changed, 3 insertions, 3 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); |