fs: Avoid accessing filep fields if it is NULL & add DEBUGASSERTs

This commit is contained in:
Alan Carvalho de Assis 2023-01-19 12:17:28 -03:00 committed by Xiang Xiao
parent 125d090b9c
commit c3a34a5956

View File

@ -269,6 +269,9 @@ int files_duplist(FAR struct filelist *plist, FAR struct filelist *clist)
int i;
int j;
DEBUGASSERT(clist);
DEBUGASSERT(plist);
ret = nxmutex_lock(&plist->fl_lock);
if (ret < 0)
{
@ -298,7 +301,10 @@ int files_duplist(FAR struct filelist *plist, FAR struct filelist *clist)
#endif
filep = &plist->fl_files[i][j];
if (filep->f_inode == NULL || (filep->f_oflags & O_CLOEXEC) != 0)
DEBUGASSERT(filep);
if (filep && (filep->f_inode == NULL ||
(filep->f_oflags & O_CLOEXEC) != 0))
{
continue;
}