diff options
author | kaa@polly.(none) <> | 2007-10-11 14:28:12 +0400 |
---|---|---|
committer | kaa@polly.(none) <> | 2007-10-11 14:28:12 +0400 |
commit | f80541e37045a7f511998718d5b89d5e9942e6a6 (patch) | |
tree | 8dd2eb20a23ac075a6d02358dc9bb587f5940b00 /myisam | |
parent | e78513165c1b4e1696167e9fac6558e4492bc815 (diff) | |
download | mariadb-git-f80541e37045a7f511998718d5b89d5e9942e6a6.tar.gz |
Fix for bug #31174: "Repair" command on MyISAM crashes with small
myisam_sort_buffer_size.
An incorrect length of the sort buffer was used when calculating the
maximum number of keys. When myisam_sort_buffer_size is small enough,
this could result in the number of keys < number of
BUFFPEK structures which in turn led to use of uninitialized BUFFPEKs.
Fixed by correcting the buffer length calculation.
Diffstat (limited to 'myisam')
-rw-r--r-- | myisam/sort.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/myisam/sort.c b/myisam/sort.c index b909a16e8e6..728e5b9673e 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -559,9 +559,10 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) if (!mergebuf) { length=param->sort_buffer_length; - while (length >= MIN_SORT_MEMORY && !mergebuf) + while (length >= MIN_SORT_MEMORY) { - mergebuf=my_malloc(length, MYF(0)); + if ((mergebuf= my_malloc(length, MYF(0)))) + break; length=length*3/4; } if (!mergebuf) @@ -897,6 +898,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, count=error=0; maxcount=keys/((uint) (Tb-Fb) +1); + DBUG_ASSERT(maxcount > 0); LINT_INIT(to_start_filepos); if (to_file) to_start_filepos=my_b_tell(to_file); |