PHYSFS_freeList(NULL) is now a safe no-op.
authorRyan C. Gordon <icculus@icculus.org>
Sat, 28 Mar 2009 17:50:54 -0400
changeset 975 653a53e51931
parent 974 5cabc31eb563
child 976 372a5232bc18
PHYSFS_freeList(NULL) is now a safe no-op.
src/physfs.c
src/physfs.h
--- a/src/physfs.c	Sat Mar 28 16:16:08 2009 -0400
+++ b/src/physfs.c	Sat Mar 28 17:50:54 2009 -0400
@@ -872,10 +872,13 @@
 void PHYSFS_freeList(void *list)
 {
     void **i;
-    for (i = (void **) list; *i != NULL; i++)
-        allocator.Free(*i);
-
-    allocator.Free(list);
+    if (list != NULL)
+    {
+        for (i = (void **) list; *i != NULL; i++)
+            allocator.Free(*i);
+
+        allocator.Free(list);
+    } /* if */
 } /* PHYSFS_freeList */
 
 
--- a/src/physfs.h	Sat Mar 28 16:16:08 2009 -0400
+++ b/src/physfs.h	Sat Mar 28 17:50:54 2009 -0400
@@ -550,7 +550,11 @@
  * 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