Skip to content

Commit

Permalink
PHYSFS_freeList(NULL) is now a safe no-op.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Mar 28, 2009
1 parent b78da18 commit fb5e8d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/physfs.c
Expand Up @@ -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 */


Expand Down
4 changes: 4 additions & 0 deletions src/physfs.h
Expand Up @@ -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
Expand Down

0 comments on commit fb5e8d9

Please sign in to comment.