summaryrefslogtreecommitdiff
path: root/source/fitz
diff options
context:
space:
mode:
authorPaul Gardiner <paul.gardiner@artifex.com>2018-01-23 10:02:43 +0000
committerPaul Gardiner <paul.gardiner@artifex.com>2018-01-24 11:19:15 +0000
commita55835a7adf8fcfc7a3906a223061e27d4c3bc38 (patch)
tree9095e1449e9754b1b8189f0d5feee6a9ecf9c2e7 /source/fitz
parent3e86abff1a7ff9b1819b37dbde769e20e34042e7 (diff)
downloadmupdf-a55835a7adf8fcfc7a3906a223061e27d4c3bc38.tar.xz
Fix failure of non-incremental document saving.
An earlier commit changed the mode used to open a file for saving so that it could also be read from. The mode used was rb+ independently of whether the saving mode was incremental or not. Doing so neglected that for non-incemental saves the file may not already exist in which case opening rb+ will fail. This commit arranges that wb+ is used in the non-incremental case.
Diffstat (limited to 'source/fitz')
-rw-r--r--source/fitz/output.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/source/fitz/output.c b/source/fitz/output.c
index 18791603..a8301a1e 100644
--- a/source/fitz/output.c
+++ b/source/fitz/output.c
@@ -205,7 +205,7 @@ fz_new_output_with_path(fz_context *ctx, const char *filename, int append)
if (errno != ENOENT)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot remove file '%s': %s", filename, strerror(errno));
}
- file = fz_fopen_utf8(filename, "rb+");
+ file = fz_fopen_utf8(filename, append ? "rb+" : "wb+");
#else
/* Ensure we create a brand new file. We don't want to clobber our old file. */
if (!append)
@@ -214,7 +214,7 @@ fz_new_output_with_path(fz_context *ctx, const char *filename, int append)
if (errno != ENOENT)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot remove file '%s': %s", filename, strerror(errno));
}
- file = fopen(filename, "rb+");
+ file = fopen(filename, append ? "rb+" : "wb+");
#endif
if (!file)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot open file '%s': %s", filename, strerror(errno));