don't leak FD

If this was called and we returned the cached mount, we leak the fopen().
Move the fopen down below the return.
This commit is contained in:
Dave Hansen 2010-10-04 16:01:38 -07:00
parent ca5069404b
commit 592cc73b5b

View file

@ -69,7 +69,7 @@ char *locate_eyefi_mount(void)
{
static char eyefi_mount[PATHNAME_MAX]; // PATH_MAX anyone?
char line[LINEBUFSZ];
FILE *mounts = fopen("/proc/mounts", "r");
FILE *mounts;
char dev[LINEBUFSZ];
char mnt[LINEBUFSZ];
@ -77,10 +77,12 @@ char *locate_eyefi_mount(void)
char opt[LINEBUFSZ];
int foo;
int bar;
if (strlen(eyefi_mount))
return &eyefi_mount[0];
mounts = fopen("/proc/mounts", "r");
while (fgets(&line[0], 1023, mounts)) {
int read;
read = sscanf(&line[0], "%s %s %s %s %d %d",