From e0263b166c8e334c388655373f2144d9bc5184b4 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Wed, 23 Dec 2009 21:51:29 +0000 Subject: [PATCH] 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 --- firmware/common/file.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/firmware/common/file.c b/firmware/common/file.c index a7facc3d32..75adc8756f 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -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;