foxygit / doom Log in
commit 921666f7046ed38ff42fe233d8cd0a5f83578418
Author:     Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Sun Jan 20 20:48:30 2019 +0100
Commit:     Fabian Greffrath <fabian@greffrath.com>
CommitDate: Sun Jan 20 20:48:30 2019 +0100

    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)