From bbcc85a9f746c161b2e23c6057e69ec7b967252b Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 28 Dec 2016 13:19:47 +0100 Subject: Add fz_terminate_buffer function. Non-destructively zero terminate a fz_buffer for use as a C string. --- source/xps/xps-zip.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source/xps') 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); -- cgit v1.2.3