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:
parent
ca5069404b
commit
592cc73b5b
1 changed files with 4 additions and 2 deletions
|
@ -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",
|
||||
|
|
Loading…
Add table
Reference in a new issue