summaryrefslogtreecommitdiff
path: root/client/mysql.cc
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay.choubey@oracle.com>2013-03-18 12:46:06 +0530
committerNirbhay Choubey <nirbhay.choubey@oracle.com>2013-03-18 12:46:06 +0530
commit6d6af5477eddcd994d6b9bd295563a02359b735f (patch)
treec01799f77c48abe53533d4ae3c2e889fe9ee65db /client/mysql.cc
parent56630dfd45b5cc70e1070c8e0f26f1f5b1b4f799 (diff)
parenta6adbd05333f0cfc7365974caa452e03cbb6fa7d (diff)
downloadmariadb-git-6d6af5477eddcd994d6b9bd295563a02359b735f.tar.gz
Merge of patch for bug#14685362 from mysql-5.1.
Diffstat (limited to 'client/mysql.cc')
-rw-r--r--client/mysql.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index edbfd532de3..5deb978a593 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
@@ -1849,7 +1849,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;
@@ -1913,6 +1913,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__) */
@@ -1970,8 +1977,17 @@ static int read_and_execute(bool interactive)
#if defined(__WIN__)
buffer.free();
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;
}