MXS-1308: Fix crash with multimaster=true

The multimaster node detection uses stacks to sort the node groups. The
size of this stack was always assumed to be positive but it was possible
that it dropped down to -1 causing a crash when the stack was accessed
with the index number.
This commit is contained in:
Markus Mäkelä 2017-07-03 02:44:37 +03:00
parent 31504585fc
commit ff22243955

View File

@ -845,7 +845,10 @@ static void visit_node(struct graph_node *node, struct graph_node **stack,
{
/** Pop invalid nodes off the stack */
node->active = false;
*stacksize -= 1;
if (*stacksize > 0)
{
*stacksize -= 1;
}
}
}
@ -1200,7 +1203,7 @@ monitorMain(void *arg)
}
if (handle->multimaster)
if (handle->multimaster && num_servers > 0)
{
/** Find all the master server cycles in the cluster graph. If
multiple masters are found, the servers with the read_only