[MXS-227] Memory leak in Galera Monitor Created: 2015-06-28  Updated: 2015-06-29  Resolved: 2015-06-29

Status: Closed
Project: MariaDB MaxScale
Component/s: galeramon
Affects Version/s: 1.1.1, 1.2.0
Fix Version/s: 1.2.0

Type: Bug Priority: Major
Reporter: Dipti Joshi (Inactive) Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None


 Description   

Memory leak between line 383 and 408 of galeramon.c in develop branch

In the following code section result from previous query should be freed before the second query (SHOW VARIABLES LIKE 'wsrep_sst_method'). Not doing so will leak memory allocated to result of previous query.

		while ((row = mysql_fetch_row(result)))
		{
			if (strcmp(row[1], "4") == 0) 
				isjoined = 1;
	
			/* Check if the node is a donor and is using xtrabackup, in this case it can stay alive */
			else if (strcmp(row[1], "2") == 0 && handle->availableWhenDonor == 1) {
				if (mysql_query(database->con, "SHOW VARIABLES LIKE 'wsrep_sst_method'") == 0
					&& (result = mysql_store_result(database->con)) != NULL)
				{
				    		if(mysql_field_count(database->con) < 2)
						{
						    mysql_free_result(result);
						    skygw_log_write(LE,"Error: Unexpected result for \"SHOW VARIABLES LIKE 'wsrep_sst_method'\". Expected 2 columns."
							    " MySQL Version: %s",version_str);
						    return;
						}
					while ((row = mysql_fetch_row(result)))
					{
						if (strncmp(row[1], "xtrabackup", 10) == 0)
							isjoined = 1;
					}
				}
			}
		}
		mysql_free_result(result);



 Comments   
Comment by markus makela [ 2015-06-29 ]

Fixed memory leak by using a second variable.

Generated at Thu Feb 08 03:57:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.