diff --git a/CASA-auth-token/client/library/engine.c b/CASA-auth-token/client/library/engine.c index 173918d8..0f598f47 100644 --- a/CASA-auth-token/client/library/engine.c +++ b/CASA-auth-token/client/library/engine.c @@ -1367,14 +1367,17 @@ UnInitializeLibrary(void) } pListEntry = g_ATSHostList.Flink; - while (pListEntry != &g_ATSHostList) + if (pListEntry) { - pHostEntry = CONTAINING_RECORD(pListEntry, ATSHostEntry, listEntry); - RemoveEntryList(pListEntry); - free(pHostEntry->pNameAndPort); - free(pHostEntry->pName); - free(pHostEntry); - pListEntry = g_ATSHostList.Flink; + while (pListEntry != &g_ATSHostList) + { + pHostEntry = CONTAINING_RECORD(pListEntry, ATSHostEntry, listEntry); + RemoveEntryList(pListEntry); + free(pHostEntry->pNameAndPort); + free(pHostEntry->pName); + free(pHostEntry); + pListEntry = g_ATSHostList.Flink; + } } DbgTrace(1, "-UnInitializeLibrary- End\n", 0);