From fb5e8d9cd2e6780ef5578fcd2068847d5bba2371 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 28 Mar 2009 17:50:54 -0400 Subject: [PATCH] PHYSFS_freeList(NULL) is now a safe no-op. --- src/physfs.c | 9 ++++++--- src/physfs.h | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/physfs.c b/src/physfs.c index 4a5dc11f..5d2cdf00 100644 --- a/src/physfs.c +++ b/src/physfs.c @@ -872,10 +872,13 @@ const PHYSFS_ArchiveInfo **PHYSFS_supportedArchiveTypes(void) void PHYSFS_freeList(void *list) { void **i; - for (i = (void **) list; *i != NULL; i++) - allocator.Free(*i); + if (list != NULL) + { + for (i = (void **) list; *i != NULL; i++) + allocator.Free(*i); - allocator.Free(list); + allocator.Free(list); + } /* if */ } /* PHYSFS_freeList */ diff --git a/src/physfs.h b/src/physfs.h index da4f4412..5c9fe7e7 100644 --- a/src/physfs.h +++ b/src/physfs.h @@ -550,7 +550,11 @@ __EXPORT__ const PHYSFS_ArchiveInfo **PHYSFS_supportedArchiveTypes(void); * Certain PhysicsFS functions return lists of information that are * dynamically allocated. Use this function to free those resources. * + * It is safe to pass a NULL here, but doing so will cause a crash in versions + * before PhysicsFS 2.1.0. + * * \param listVar List of information specified as freeable by this function. + * Passing NULL is safe; it is a valid no-op. * * \sa PHYSFS_getCdRomDirs * \sa PHYSFS_enumerateFiles