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:
Frank Gevaerts 2009-12-23 21:51:29 +00:00
parent 6216627559
commit e0263b166c

View file

@ -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;