diff options
author | Sergei Golubchik <sergii@pisem.net> | 2011-12-14 10:59:24 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2011-12-14 10:59:24 +0100 |
commit | 8404b44a845e8a827bf1986fe4450673782bfdae (patch) | |
tree | 97b171dcce85cb3f288d41d6de5f75234f099814 /sql/sql_string.h | |
parent | 818af42f1de640f3951fcfde0cb9b7b76d06a01e (diff) | |
download | mariadb-git-8404b44a845e8a827bf1986fe4450673782bfdae.tar.gz |
fix new String:realloc* variants always to zero-terminate the string
Diffstat (limited to 'sql/sql_string.h')
-rw-r--r-- | sql/sql_string.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sql/sql_string.h b/sql/sql_string.h index fcf04fb7690..7412022baf4 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -255,17 +255,30 @@ public: return real_alloc(arg_length); } bool real_alloc(uint32 arg_length); // Empties old string - bool realloc(uint32 arg_length); + bool realloc_raw(uint32 arg_length); + bool realloc(uint32 arg_length) + { + if (realloc_raw(arg_length)) + return TRUE; + Ptr[arg_length]=0; // This make other funcs shorter + return FALSE; + } bool realloc_with_extra(uint32 arg_length) { if (extra_alloc < 4096) extra_alloc= extra_alloc*2+128; - return realloc(arg_length + extra_alloc); + if (realloc_raw(arg_length + extra_alloc)) + return TRUE; + Ptr[arg_length]=0; // This make other funcs shorter + return FALSE; } bool realloc_with_extra_if_needed(uint32 arg_length) { if (arg_length < Alloced_length) + { + Ptr[arg_length]=0; // behave as if realloc was called. return 0; + } return realloc_with_extra(arg_length); } inline void shrink(uint32 arg_length) // Shrink buffer |