summaryrefslogtreecommitdiff
path: root/base/sfxcommon.c
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2015-07-30 17:27:23 +0100
committerChris Liddell <chris.liddell@artifex.com>2015-08-06 10:30:08 +0100
commit1fae53a708fca6c2ac0417bc23f5d095cc379250 (patch)
tree1ae77835a99385e70b009a574f80a47b104e7b89 /base/sfxcommon.c
parent6fb23cff7abcef91d03b43454d2d40d79c5e83da (diff)
downloadghostpdl-1fae53a708fca6c2ac0417bc23f5d095cc379250.tar.gz
Bug 696101: fix uses of the sfopen API.
The stream API in GS is defined as *always* opening files in binary mode, where applicable, so there is no need for the API clients to specify binary mode. This is previously been benign, and thus ignored, but reportedly ending up with a duplicate 'b' character in the mode causes a crash on Windows 10. No cluster differences.
Diffstat (limited to 'base/sfxcommon.c')
-rw-r--r--base/sfxcommon.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/base/sfxcommon.c b/base/sfxcommon.c
index cec104df8..5177a62b6 100644
--- a/base/sfxcommon.c
+++ b/base/sfxcommon.c
@@ -23,6 +23,7 @@
#include "gp.h"
#include "gserrors.h"
#include "stream.h"
+#include "assert_.h"
#define DEFAULT_BUFFER_SIZE 2048
const uint file_default_buffer_size = DEFAULT_BUFFER_SIZE;
@@ -66,6 +67,14 @@ file_open_stream(const char *fname, uint len, const char *file_access,
FILE *file;
char fmode[4]; /* r/w/a, [+], [b], null */
+#ifdef DEBUG
+ if (strlen(gp_fmode_binary_suffix) > 0) {
+ if (strchr(file_access, gp_fmode_binary_suffix[0]) != NULL)
+ dmprintf(mem, "\nWarning: spurious 'b' character in file access mode\n");
+ assert(strchr(file_access, gp_fmode_binary_suffix[0]) == NULL);
+ }
+#endif
+
if (!iodev)
iodev = iodev_default(mem);
code = file_prepare_stream(fname, len, file_access, buffer_size, ps, fmode, mem);