Hi, Mark! On Jun 06, MARK CALLAGHAN wrote:
Why doesn't the shrink() method in sql_string.h check the value of alloced before calling my_realloc? my_realloc might free Ptr, but when alloced=0 that memory is not owned by the string.
You're right, of course. I also agree with you that it cannot be triggered at the moment. We'll wait for MySQL fix to avoid unnecessary merge conflicts.
2 bk@work | inline void shrink(uint32 arg_length) // Shrink buffer 2 bk@work | { 2 bk@work | if (arg_length < Alloced_length) 2 bk@work | { 2 bk@work | char *new_ptr; 2 bk@work | if (!(new_ptr=(char*) my_realloc(Ptr,arg_length,MYF(0)))) 2 bk@work | { 228 sasha@m | Alloced_length = 0; 2 bk@work | real_alloc(arg_length); 2 bk@work | } 2 bk@work | else 2 bk@work | { 2 bk@work | Ptr=new_ptr; 2 bk@work | Alloced_length=arg_length; 2 bk@work | } 2 bk@work | } 2 bk@work | }
Regards, Sergei