summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorV Narayanan <v.narayanan@sun.com>2009-06-19 17:29:21 +0530
committerV Narayanan <v.narayanan@sun.com>2009-06-19 17:29:21 +0530
commit336c81061872bd5610670edd5595bf7ac1e41fad (patch)
tree434ed5bfe3e137ce745b237f9baacff9adc34715 /include
parent37d2019d1756d630d48ab23ca41f7c595862c7f4 (diff)
downloadmariadb-git-336c81061872bd5610670edd5595bf7ac1e41fad.tar.gz
Bug#43572 Handle failures from hash_init
Failure to allocate memory for the hash->array element, caused hash_init to return without initializing the other members of the hash. Thus although the dynamic array buffer may be allocated at a later point in the code, the incompletely initialized hash caused fatal failures. This patch moves the initialization of the other members of the hash above the array allocation, so that the usage of this hash will not result in fatal failures. include/hash.h: Bug#43572 Handle failures from hash_init hash_inited is used to verify that the hash is valid. After the change induced by the current patch hash->array.buffer !=0 is not a valid check for this condition, since, the dynamic array can be allocated even at a later time. Bootstrap SQL script is setting some variables, which are actually not set due to this hash_inited issue. Thus we get empty grant tables. A better way to check if the hash is valid is to verify that hash->blength is greater than 0. mysys/hash.c: Bug#43572 Handle failures from hash_init Move the initialization of the other members of the hash above the array allocation, so that the usage of this hash will not result in fatal failures.
Diffstat (limited to 'include')
-rw-r--r--include/hash.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/hash.h b/include/hash.h
index 97e947d7c6a..56b54a15a8c 100644
--- a/include/hash.h
+++ b/include/hash.h
@@ -63,7 +63,7 @@ void hash_replace(HASH *hash, HASH_SEARCH_STATE *state, byte *new_row);
my_bool hash_check(HASH *hash); /* Only in debug library */
#define hash_clear(H) bzero((char*) (H),sizeof(*(H)))
-#define hash_inited(H) ((H)->array.buffer != 0)
+#define hash_inited(H) ((H)->blength != 0)
#define hash_init_opt(A,B,C,D,E,F,G,H) \
(!hash_inited(A) && _hash_init(A,B,C,D,E,F,G, H CALLER_INFO))