aboutsummaryrefslogtreecommitdiff
path: root/midend.c
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2022-10-17 00:59:18 +0100
committerBen Harris <bjh21@bjh21.me.uk>2022-10-20 23:59:05 +0100
commit7f4d038258d2bd585a0dce87177bf429d168ffb5 (patch)
treeabb96a54ac13cbad2830c8ca6cf0b5bde8b2be68 /midend.c
parent304796f9f184a783d0af21e445c690ed69de048b (diff)
downloadpuzzles-7f4d038258d2bd585a0dce87177bf429d168ffb5.zip
puzzles-7f4d038258d2bd585a0dce87177bf429d168ffb5.tar.gz
puzzles-7f4d038258d2bd585a0dce87177bf429d168ffb5.tar.bz2
puzzles-7f4d038258d2bd585a0dce87177bf429d168ffb5.tar.xz
Assert that everything written to a save file is printable ASCII
Apart from the newlines of course.
Diffstat (limited to 'midend.c')
-rw-r--r--midend.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/midend.c b/midend.c
index 395288e..c0c61b7 100644
--- a/midend.c
+++ b/midend.c
@@ -2019,7 +2019,9 @@ void midend_serialise(midend *me,
char lbuf[9]; \
copy_left_justified(lbuf, sizeof(lbuf), h); \
sprintf(hbuf, "%s:%d:", lbuf, (int)strlen(str)); \
+ assert_printable_ascii(hbuf); \
write(wctx, hbuf, strlen(hbuf)); \
+ assert_printable_ascii(str); \
write(wctx, str, strlen(str)); \
write(wctx, "\n", 1); \
} while (0)
@@ -2115,7 +2117,6 @@ void midend_serialise(midend *me,
*/
if (me->ui) {
char *s = me->ourgame->encode_ui(me->ui);
- assert_printable_ascii(s);
if (s) {
wr("UI", s);
sfree(s);