diff options
author | Nirbhay Choubey <nirbhay.choubey@oracle.com> | 2013-03-18 12:44:38 +0530 |
---|---|---|
committer | Nirbhay Choubey <nirbhay.choubey@oracle.com> | 2013-03-18 12:44:38 +0530 |
commit | a6adbd05333f0cfc7365974caa452e03cbb6fa7d (patch) | |
tree | c53fb7bf4e722922640ea6f5ab744d797ca682c9 /client | |
parent | cc5876d2d2b4105d3f0cab8be1f09a67667bf8fd (diff) | |
download | mariadb-git-a6adbd05333f0cfc7365974caa452e03cbb6fa7d.tar.gz |
Bug#14685362 : MEMORY LEAKS IN MYSQL CLIENT IN
INTERACTIVE MODE
In interactive mode, libedit/readline allocates memory
for every new line entered & later the allocated memory
never gets freed.
Fixed by freeing the allocated memory blocks appropriately.
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index 965b1929af8..822eeb1a95e 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1,5 +1,5 @@ /* - Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1869,7 +1869,7 @@ static int read_and_execute(bool interactive) String buffer; #endif - char *line; + char *line= NULL; char in_string=0; ulong line_number=0; bool ml_comment= 0; @@ -1944,6 +1944,13 @@ static int read_and_execute(bool interactive) #else if (opt_outfile) fputs(prompt, OUTFILE); + /* + free the previous entered line. + Note: my_free() cannot be used here as the memory was allocated under + the readline/libedit library. + */ + if (line) + free(line); line= readline(prompt); #endif /* defined(__WIN__) || defined(__NETWARE__) */ @@ -2003,8 +2010,17 @@ static int read_and_execute(bool interactive) #endif #if defined(__WIN__) tmpbuf.free(); +#else + if (interactive) + /* + free the last entered line. + Note: my_free() cannot be used here as the memory was allocated under + the readline/libedit library. + */ + free(line); #endif + return status.exit_status; } |