Skip to content

Commit

Permalink
Fixed leaking file handle on BeOS during CD-ROM detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Nov 14, 2010
1 parent 4d567a0 commit 7d253b1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/platform_beos.cpp
Expand Up @@ -125,15 +125,16 @@ static void tryDir(const char *d, PHYSFS_StringCallback callback, void *data)
else
{
bool add_it = false;
int devfd;
device_geometry g;

if (strcmp(e.name, "raw") == 0) /* ignore partitions. */
{
int devfd = open(name, O_RDONLY);
const int devfd = open(name, O_RDONLY);
if (devfd >= 0)
{
if (ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0)
const int rc = ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g));
close(devfd);
if (rc >= 0)
{
if (g.device_type == B_CD)
{
Expand All @@ -147,8 +148,6 @@ static void tryDir(const char *d, PHYSFS_StringCallback callback, void *data)
} /* if */
} /* if */
} /* if */

close(devfd);
} /* else */
} /* while */
} /* tryDir */
Expand Down

0 comments on commit 7d253b1

Please sign in to comment.