Forráskód Böngészése

Added some malloc() failure checks in CD-ROM detection code.

Ryan C. Gordon 24 éve
szülő
commit
42a386c247
1 módosított fájl, 4 hozzáadás és 0 törlés
  1. 4 0
      platform/unix.c

+ 4 - 0
platform/unix.c

@@ -82,6 +82,8 @@ char **__PHYSFS_platformDetectAvailableCDs(void)
     int mounts;
     int mounts;
     int ii;
     int ii;
 
 
+    BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
+
     mounts = getmntinfo( &mntbufp, MNT_WAIT );
     mounts = getmntinfo( &mntbufp, MNT_WAIT );
 
 
     for ( ii=0; ii < mounts; ++ii ) {
     for ( ii=0; ii < mounts; ++ii ) {
@@ -125,6 +127,8 @@ char **__PHYSFS_platformDetectAvailableCDs(void)
     FILE *mounts = NULL;
     FILE *mounts = NULL;
     struct mntent *ent = NULL;
     struct mntent *ent = NULL;
 
 
+    BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
+
     *retval = NULL;
     *retval = NULL;
     mounts = setmntent("/etc/mtab", "r");
     mounts = setmntent("/etc/mtab", "r");
     BAIL_IF_MACRO(mounts == NULL, ERR_IO_ERROR, retval);
     BAIL_IF_MACRO(mounts == NULL, ERR_IO_ERROR, retval);