aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2023-04-23 14:53:11 +0100
committerSimon Tatham <anakin@pobox.com>2023-04-23 14:53:11 +0100
commit35cd44c563ec58e00a89109ef1f5450b08a3faa6 (patch)
treebc36661556f04dfe81c703faf69d9ab5112063f3
parent5c0def1850b2c09af300f09cd48f714f2505d217 (diff)
downloadpuzzles-35cd44c563ec58e00a89109ef1f5450b08a3faa6.zip
puzzles-35cd44c563ec58e00a89109ef1f5450b08a3faa6.tar.gz
puzzles-35cd44c563ec58e00a89109ef1f5450b08a3faa6.tar.bz2
puzzles-35cd44c563ec58e00a89109ef1f5450b08a3faa6.tar.xz
make_prefs_path(): tolerate NULL inputs.
Just noticed that if prefs_dir() returns NULL, we'll already have passed it to this function before the calling functions get round to checking. I think it's less wordy all round to make this helper function propagate NULL than to mess about with lots of extra if statements in between all the calls.
-rw-r--r--misc.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/misc.c b/misc.c
index f0c4abd..5621597 100644
--- a/misc.c
+++ b/misc.c
@@ -511,6 +511,9 @@ char *make_prefs_path(const char *dir, const char *sep,
char *path, *p;
const char *q;
+ if (!dir || !sep || !game || !suffix)
+ return NULL;
+
path = snewn(dirlen + seplen + gamelen + suffixlen + 1, char);
p = path;