• V Narayanan's avatar
    Bug#43572 Handle failures from hash_init · 336c8106
    V Narayanan authored
          
    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.
    336c8106
hash.c 17.7 KB