Correctly handle reading/writing after EOF.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 2 Feb 2011 21:02:54 +0000 (21:02 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 2 Feb 2011 21:02:54 +0000 (21:02 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4674 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/io/kfile_block.c

index a4278fb0037441d3e34b0e99562f0dd95dedd85f..e3bcdd3917fc1a21c6461701972900a17ffb7663 100644 (file)
@@ -62,6 +62,8 @@ INLINE KFileBlock * KFILEBLOCK_CAST(KFile *fd)
        while (size) \
        { \
                block_idx_t id = (fd)->seek_pos / fb->blk->blk_size; \
+               if (id >= fb->blk->blk_cnt) \
+                       break; \
                size_t offset = (fd)->seek_pos % fb->blk->blk_size; \
                size_t count = MIN(size, (size_t)(fb->blk->blk_size - offset)); \
                size_t ret_len = kblock_##dir(fb->blk, id, buf, offset, count); \