only get the file pointer if fd is actually valid.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24105 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
6216627559
commit
e0263b166c
1 changed files with 4 additions and 1 deletions
|
@ -485,13 +485,16 @@ static int readwrite(int fd, void* buf, long count, bool write)
|
|||
{
|
||||
long sectors;
|
||||
long nread=0;
|
||||
struct filedesc* file = &openfiles[fd];
|
||||
struct filedesc* file;
|
||||
int rc;
|
||||
|
||||
if (fd < 0 || fd > MAX_OPEN_FILES-1) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
file = &openfiles[fd];
|
||||
|
||||
if ( !file->busy ) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
|
|
Loading…
Reference in a new issue