summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2009-12-23 21:51:29 +0000
committerFrank Gevaerts <frank@gevaerts.be>2009-12-23 21:51:29 +0000
commite0263b166c8e334c388655373f2144d9bc5184b4 (patch)
tree328d8f6541c73e4c0b66362edaa794b88018b5db /firmware
parent62166275596b10904e3a962c6b0e0cd448268b63 (diff)
downloadrockbox-e0263b166c8e334c388655373f2144d9bc5184b4.tar.gz
rockbox-e0263b166c8e334c388655373f2144d9bc5184b4.tar.bz2
rockbox-e0263b166c8e334c388655373f2144d9bc5184b4.zip
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
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/file.c5
1 files changed, 4 insertions, 1 deletions
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;