Bug #72591 minor memory leak on failure in function check_temp_dir

Submitted: 9 May 2014 8:36
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.6.20 OS:Any
Assigned to: CPU Architecture:Any
Tags: Leak, memory leak, slave_load_tmpdir

[9 May 2014 8:36] Shane Bester
Description:
Memory for unique_tmp_file_name is allocated via my_malloc but not freed if mysql_file_create failed to write into the slave_load_tmpdir.

[ERROR] Slave SQL: Unable to use slave's temporary directory /slavetmp - Can't create/write to file '/slavetmp/SQL_LOAD-3b51bb28-d727-11e3-9464-08002705be5e' (Errcode: 13 - Permission denied), Error_code: 1

==31785== 586 bytes in 1 blocks are definitely lost in loss record 1 of 1
==31785==    at 0x4A078E4: malloc (vg_replace_malloc.c:291)
==31785==    by 0x8CF5F4: my_malloc (my_malloc.c:38)
==31785==    by 0x89F356: handle_slave_sql (rpl_slave.cc:4570)
==31785==    by 0x3FF8E07D13: start_thread (pthread_create.c:309)
==31785==    by 0x35372F168C: clone (clone.S:115)

How to repeat:
read the code

Suggested fix:
=== modified file 'sql/rpl_slave.cc'
--- sql/rpl_slave.cc    2014-05-08 12:47:46 +0000
+++ sql/rpl_slave.cc    2014-05-09 08:34:04 +0000
@@ -4571,6 +4571,7 @@
                              unique_tmp_file_name, CREATE_MODE,
                              O_WRONLY | O_BINARY | O_EXCL | O_NOFOLLOW,
                              MYF(MY_WME))) < 0)
+  my_free(unique_tmp_file_name);
   DBUG_RETURN(1);

   /*

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.047 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.