From 921666f7046ed38ff42fe233d8cd0a5f83578418 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Sun, 20 Jan 2019 20:48:30 +0100 Subject: [PATCH] glob: let I_NextGlob() return NULL if (glob == NULL) If a non-existent directory is passed over to I_StartGlob(), e.g. when moving config files between computers, it will return NULL. If this return value is then fed into I_NextGlob(), it will trigger a segmentation fault. Add a check to the latter if (glob == NULL) and let it return NULL itself in this case. --- src/i_glob.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/i_glob.c b/src/i_glob.c index 9df9b611..72fc090d 100644 --- a/src/i_glob.c +++ b/src/i_glob.c @@ -319,6 +319,11 @@ const char *I_NextGlob(glob_t *glob) { const char *result; + if (glob == NULL) + { + return NULL; + } + // In unsorted mode we just return the filenames as we read // them back from the system API. if ((glob->flags & GLOB_FLAG_SORTED) == 0)