diff options
Diffstat (limited to 'client/mysql.cc')
-rw-r--r-- | client/mysql.cc | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index db4557d10bc..7ee3021c4fc 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1,6 +1,6 @@ /* - Copyright (c) 2000, 2012, Oracle and/or its affiliates. - Copyright (c) 2009, 2012, Monty Program Ab. + Copyright (c) 2000, 2013, Oracle and/or its affiliates. + Copyright (c) 2009, 2013, Monty Program Ab. 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 @@ -1886,7 +1886,7 @@ static int read_and_execute(bool interactive) String buffer; #endif - char *line= 0; + char *line= NULL; char in_string=0; ulong line_number=0; bool ml_comment= 0; @@ -1961,6 +1961,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__) */ @@ -2020,8 +2027,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; } |