diff options
-rw-r--r-- | sql/item_geofunc.cc | 2 | ||||
-rw-r--r-- | sql/item_strfunc.cc | 16 | ||||
-rw-r--r-- | sql/sql_cache.cc | 3 | ||||
-rw-r--r-- | sql/sql_class.cc | 2 | ||||
-rw-r--r-- | sql/sql_string.cc | 3 |
5 files changed, 11 insertions, 15 deletions
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 4c2a2fa8b11..1f1b5a6ceed 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -916,7 +916,7 @@ String *Item_func_point::val_str(String *str) if ((null_value= (args[0]->null_value || args[1]->null_value || - str->realloc(4/*SRID*/ + 1 + 4 + SIZEOF_STORED_DOUBLE * 2)))) + str->alloc(4/*SRID*/ + 1 + 4 + SIZEOF_STORED_DOUBLE * 2)))) return 0; str->set_charset(&my_charset_bin); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index c914c6cbdf8..5333750d908 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -255,7 +255,7 @@ String *Item_func_sha2::val_str_ascii(String *str) Since we're subverting the usual String methods, we must make sure that the destination has space for the bytes we're about to write. */ - str->realloc((uint) digest_length*2 + 1); /* Each byte as two nybbles */ + str->alloc((uint) digest_length*2 + 1); /* Each byte as two nybbles */ /* Convert the large number to a string-hex representation. */ array_to_hex((char *) str->ptr(), digest_buf, (uint)digest_length); @@ -762,7 +762,7 @@ String *Item_func_des_encrypt::val_str(String *str) tail= 8 - (res_length % 8); // 1..8 marking extra length res_length+=tail; - if (tmp_arg.realloc(res_length)) + if (tmp_arg.alloc(res_length)) goto error; tmp_arg.length(0); tmp_arg.append(res->ptr(), res->length()); @@ -770,7 +770,6 @@ String *Item_func_des_encrypt::val_str(String *str) if (tmp_arg.append(append_str, tail) || str->alloc(res_length+1)) goto error; tmp_arg[res_length-1]=tail; // save extra length - str->realloc(res_length+1); str->length(res_length+1); str->set_charset(&my_charset_bin); (*str)[0]=(char) (128 | key_number); @@ -1017,7 +1016,7 @@ String *Item_func_concat_ws::val_str(String *str) { uint new_len = MY_MAX(tmp_value.alloced_length() * 2, concat_len); - if (tmp_value.realloc(new_len)) + if (tmp_value.alloc(new_len)) goto null; } } @@ -1072,8 +1071,7 @@ String *Item_func_reverse::val_str(String *str) /* An empty string is a special case as the string pointer may be null */ if (!res->length()) return make_empty_result(); - if (str->alloced_length() < res->length() && - str->realloc(res->length())) + if (str->alloc(res->length())) { null_value= 1; return 0; @@ -4178,7 +4176,7 @@ String *Item_func_compress::val_str(String *str) // Check new_size overflow: new_size <= res->length() if (((uint32) (new_size+5) <= res->length()) || - str->realloc((uint32) new_size + 4 + 1)) + str->alloc((uint32) new_size + 4 + 1)) { null_value= 1; return 0; @@ -4250,7 +4248,7 @@ String *Item_func_uncompress::val_str(String *str) max_allowed_packet)); goto err; } - if (str->realloc((uint32)new_size)) + if (str->alloc((uint32)new_size)) goto err; if ((err= uncompress((Byte*)str->ptr(), &new_size, @@ -4279,7 +4277,7 @@ String *Item_func_uuid::val_str(String *str) DBUG_ASSERT(fixed == 1); uchar guid[MY_UUID_SIZE]; - str->realloc(MY_UUID_STRING_LENGTH+1); + str->alloc(MY_UUID_STRING_LENGTH+1); str->length(MY_UUID_STRING_LENGTH); str->set_charset(system_charset_info); my_uuid(guid); diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 76b2d6db247..44211fca506 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -480,8 +480,7 @@ static void make_base_query(String *new_query, /* We do not support UCS2, UTF16, UTF32 as a client character set */ DBUG_ASSERT(current_thd->variables.character_set_client->mbminlen == 1); - new_query->length(0); // Don't copy anything from old buffer - if (new_query->realloc(query_length + additional_length)) + if (new_query->alloc(query_length + additional_length)) { /* We could not allocate the query. Use original query for diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 77bc6494732..66f6e01de33 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3220,7 +3220,7 @@ int select_export::send_data(List<Item> &items) ((uint64) res->length() / res->charset()->mbminlen + 1) * write_cs->mbmaxlen + 1; set_if_smaller(estimated_bytes, UINT_MAX32); - if (cvt_str.realloc((uint32) estimated_bytes)) + if (cvt_str.alloc((uint32) estimated_bytes)) { my_error(ER_OUTOFMEMORY, MYF(ME_FATAL), (uint32) estimated_bytes); goto err; diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 5d5cc90431b..e7acabe8bee 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -103,8 +103,7 @@ bool String::realloc_raw(size_t alloc_length) (thread_specific ? MY_THREAD_SPECIFIC : 0))))) { - if (str_length > len - 1) - str_length= 0; + DBUG_ASSERT(str_length < len); if (str_length) // Avoid bugs in memcpy on AIX memcpy(new_ptr,Ptr,str_length); new_ptr[str_length]=0; |