summaryrefslogtreecommitdiff
path: root/sql/mf_iocache.cc
diff options
context:
space:
mode:
authorunknown <sasha@mysql.sashanet.com>2000-11-16 22:59:50 -0700
committerunknown <sasha@mysql.sashanet.com>2000-11-16 22:59:50 -0700
commit02e6c9634ded99db7fce9844723c3115c0cfc2a4 (patch)
treed8068f5b0d790b22d0da98d40533c9240c853251 /sql/mf_iocache.cc
parent3dc874a7c09932191a8105fc922ea45fde751a67 (diff)
downloadmariadb-git-02e6c9634ded99db7fce9844723c3115c0cfc2a4.tar.gz
fixed bugs in IO_CACHE and Load_event constructor. The code now passes
replication test suite mysys/mf_iocache2.c: fixed bug in my_b_seek sql/log_event.cc: fixed bug in Load_event constructor, removed compiler warnings sql/mf_iocache.cc: _my_b_read could overflow a small buffer if the leftovers happened to be more than we wanted to read. info->pos_in_file was also not being set correctly
Diffstat (limited to 'sql/mf_iocache.cc')
-rw-r--r--sql/mf_iocache.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc
index 7f85cc06f57..c1e6b37a848 100644
--- a/sql/mf_iocache.cc
+++ b/sql/mf_iocache.cc
@@ -240,12 +240,17 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count)
{
uint length,diff_length,left_length;
my_off_t max_length, pos_in_file;
-
- memcpy(Buffer,info->rc_pos,
- (size_t) (left_length=(uint) (info->rc_end-info->rc_pos)));
- Buffer+=left_length;
- Count-=left_length;
- pos_in_file=info->pos_in_file+(uint) (info->rc_end - info->buffer);
+
+ if((left_length=(uint) (info->rc_end-info->rc_pos)))
+ {
+ if(Count < left_length)
+ left_length = Count;
+ memcpy(Buffer,info->rc_pos,
+ (size_t) (left_length));
+ Buffer+=left_length;
+ Count-=left_length;
+ }
+ pos_in_file=info->pos_in_file+ left_length;
if (info->seek_not_done)
{ /* File touched, do seek */
VOID(my_seek(info->file,pos_in_file,MY_SEEK_SET,MYF(0)));