Skip to content

Commit

Permalink
findfirst_f: fix handle leaks [#92]
Browse files Browse the repository at this point in the history
  • Loading branch information
stsp committed Apr 3, 2024
1 parent 691f6ff commit fe97f9c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,18 @@ typedef struct ffblk finddata_t;
#define FINDDATA_T_WDATE_DAY(f) ((f).ff_fdate)&0x1F
#define FINDDATA_T_WTIME_HOUR(f) ((f).ff_ftime>>11)&0x1F
#define FINDDATA_T_WTIME_MIN(f) ((f).ff_ftime>>5)&0x3F
static inline int findclose_f(long handle);
static inline int findfirst_f(const char *pathname, finddata_t *ff, int attrib, long *handle)
{
int err = findfirst(pathname, ff, attrib);
if (err)
return err;
if (attrib == FA_DIREC && FINDDATA_T_ATTRIB(*ff) != attrib)
if (attrib == FA_DIREC && FINDDATA_T_ATTRIB(*ff) != attrib) {
findclose_f(ff->lfn_handle);
return -1;
}
if (handle)
*handle = ff->lfn_handle;
return 0;
}
static inline int findnext_f(finddata_t *ff, long handle)
Expand Down

0 comments on commit fe97f9c

Please sign in to comment.