From 943904cdd92d747b69f1f8bd8b38d150cb506d1d Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 8 Jun 2002 08:50:00 +0000 Subject: [PATCH] Fixed a crashbug when calling PHYSFS_deinit() twice in a row. --- physfs.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/physfs.c b/physfs.c index 71dc911..e143751 100644 --- a/physfs.c +++ b/physfs.c @@ -111,7 +111,7 @@ static ErrMsg *findErrorForCurrentThread(void) ErrMsg *i; PHYSFS_uint64 tid; - if (initialized) + if (errorLock != NULL) __PHYSFS_platformGrabMutex(errorLock); if (errorMessages != NULL) @@ -122,13 +122,14 @@ static ErrMsg *findErrorForCurrentThread(void) { if (i->tid == tid) { - __PHYSFS_platformReleaseMutex(errorLock); + if (errorLock != NULL) + __PHYSFS_platformReleaseMutex(errorLock); return(i); } /* if */ } /* for */ } /* if */ - if (initialized) + if (errorLock != NULL) __PHYSFS_platformReleaseMutex(errorLock); return(NULL); /* no error available. */ @@ -153,10 +154,14 @@ void __PHYSFS_setError(const char *str) memset((void *) err, '\0', sizeof (ErrMsg)); err->tid = __PHYSFS_platformGetThreadID(); - __PHYSFS_platformGrabMutex(errorLock); + if (errorLock != NULL) + __PHYSFS_platformGrabMutex(errorLock); + err->next = errorMessages; errorMessages = err; - __PHYSFS_platformReleaseMutex(errorLock); + + if (errorLock != NULL) + __PHYSFS_platformReleaseMutex(errorLock); } /* if */ err->errorAvailable = 1; @@ -188,6 +193,8 @@ static void freeErrorMessages(void) next = i->next; free(i); } /* for */ + + errorMessages = NULL; } /* freeErrorMessages */