summaryrefslogtreecommitdiff
path: root/source/xps
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-12-28 13:19:47 +0100
committerTor Andersson <tor.andersson@artifex.com>2017-01-09 13:21:40 +0100
commitbbcc85a9f746c161b2e23c6057e69ec7b967252b (patch)
tree8ead60bd762cc0cbf945c002c769e74699594c0b /source/xps
parente9667e7f8ab7c154d8932916a22c33cf2bad0445 (diff)
downloadmupdf-bbcc85a9f746c161b2e23c6057e69ec7b967252b.tar.xz
Add fz_terminate_buffer function.
Non-destructively zero terminate a fz_buffer for use as a C string.
Diffstat (limited to 'source/xps')
-rw-r--r--source/xps/xps-zip.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/source/xps/xps-zip.c b/source/xps/xps-zip.c
index 53ea15f9..fe1dcce8 100644
--- a/source/xps/xps-zip.c
+++ b/source/xps/xps-zip.c
@@ -92,11 +92,8 @@ xps_read_part(fz_context *ctx, xps_document *doc, char *partname)
}
}
- fz_write_buffer_byte(ctx, buf, 0); /* zero-terminate */
-
- /* take over the data */
- /* size doesn't include the added zero-terminator */
- size = fz_buffer_extract(ctx, buf, &data) - 1;
+ fz_terminate_buffer(ctx, buf); /* zero-terminate */
+ size = fz_buffer_extract(ctx, buf, &data); /* take over the data ('size' excludes the zero terminator) */
fz_drop_buffer(ctx, buf);
return xps_new_part(ctx, doc, partname, data, size);