summaryrefslogtreecommitdiff
path: root/myisam
diff options
context:
space:
mode:
authorunknown <kaa@polly.(none)>2007-10-11 14:28:12 +0400
committerunknown <kaa@polly.(none)>2007-10-11 14:28:12 +0400
commit1c7b80dff98a1afdc82981e3466874596a8927d1 (patch)
tree8dd2eb20a23ac075a6d02358dc9bb587f5940b00 /myisam
parent7a2bb241bd0a80303385ef251ccb422c99c33a0b (diff)
downloadmariadb-git-1c7b80dff98a1afdc82981e3466874596a8927d1.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. myisam/sort.c: Use a correct buffer length when calculating the maximum number of keys. Assert that for each BUFFPEK structure there is at least one corresponding key. Otherwise we would fail earlier and not reach merge_buffers(). mysql-test/r/repair.result: Added a test case for bug #31174. mysql-test/t/repair.test: Added a test case for bug #31174.
Diffstat (limited to 'myisam')
-rw-r--r--myisam/sort.c6
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);