Hi.
On Mon 2002-11-18 at 14:59:46 +0200, monty@stripped wrote:
[...]
> mysys/mf_keycache.c
> 1.15 02/11/18 14:59:43 monty@stripped +6 -5
> Small change to make key cache code cleaer
>
> --- 1.14/mysys/mf_keycache.c Sat May 19 10:14:04 2001
> +++ 1.15/mysys/mf_keycache.c Mon Nov 18 14:59:43 2002
> @@ -548,13 +548,14 @@
> count++;
> }
> /* Only allocate a new buffer if its bigger than the one we have */
> - if (count <= FLUSH_CACHE ||
> - !(cache=(SEC_LINK**) my_malloc(sizeof(SEC_LINK*)*count,MYF(0))))
> + if (count > FLUSH_CACHE)
> {
> - cache=cache_buff; /* Fall back to safe buffer */
> - count=FLUSH_CACHE;
> + if (!(cache=(SEC_LINK**) my_malloc(sizeof(SEC_LINK*)*count,MYF(0))))
> + {
> + cache=cache_buff; /* Fall back to safe buffer */
> + count=FLUSH_CACHE;
> + }
> }
> - end=cache+count;
> }
Sorry, if I am ignorant here, but before the change, it was assured,
that
count <= FLASH_CACHE
after this code part. Now, it may be left at a bigger value (if the
call to my_malloc fails). After this snippet, count is used to limit a
range, AFAICS:
/* Go through the keys and write them to buffer to be flushed */
end=(pos=cache)+count;
for (used=changed_blocks[(uint) file & CHANGED_BLOCKS_MASK];
used ;
used=next)
{
next=used->next_changed;
if (used->file == file)
{
if (type != FLUSH_IGNORE_CHANGED)
{
if (pos == end)
{
if ((error=flush_cached_blocks(file, cache, count)))
last_errno=error;
pos=cache;
}
*pos++=used;
_my_cache_write++;
}
if (type != FLUSH_KEEP && type != FLUSH_FORCE_WRITE)
{
/* This will not destroy position or data */
_my_blocks_changed--;
free_block(used);
}
else
link_changed_to_file(used,file);
}
}
So, does this still work? It looks to me as if *pos will be
incremented beyond the end of the cache.
No long explanation needed, I just wanted to make you aware of this,
in case it is an issue.
Regards,
Benjamin.
--
benjamin-mysql@stripped