From d4d471bdaa383d1a50eeba30d7c0030b2dc4a55b Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 9 Mar 2018 14:50:37 -0500 Subject: [PATCH] ignorecase: Don't crash if enumeration returned a NULL pointer. --- extras/ignorecase.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/extras/ignorecase.c b/extras/ignorecase.c index 3a58f1b..869c213 100644 --- a/extras/ignorecase.c +++ b/extras/ignorecase.c @@ -50,18 +50,22 @@ static int locateOneElement(char *buf) ptr++; /* point past dirsep to entry itself. */ } /* else */ - for (i = rc; *i != NULL; i++) + if (rc != NULL) { - if (PHYSFS_utf8stricmp(*i, ptr) == 0) + for (i = rc; *i != NULL; i++) { - strcpy(ptr, *i); /* found a match. Overwrite with this case. */ - PHYSFS_freeList(rc); - return 1; - } /* if */ - } /* for */ + if (PHYSFS_utf8stricmp(*i, ptr) == 0) + { + strcpy(ptr, *i); /* found a match. Overwrite with this case. */ + PHYSFS_freeList(rc); + return 1; + } /* if */ + } /* for */ + + PHYSFS_freeList(rc); + } /* if */ /* no match at all... */ - PHYSFS_freeList(rc); return 0; } /* locateOneElement */