summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorgkodinov/kgeorge@magare.gmz <>2007-07-10 10:43:12 +0300
committergkodinov/kgeorge@magare.gmz <>2007-07-10 10:43:12 +0300
commit7735a2f2ebe54e6df926097b6c43d2aaba5fbcc5 (patch)
tree327022a9fb698b4902ca4a9fb9564e1adc794a2d /mysys
parent7cab171f644ee952c68c5ed7c551e900432f081f (diff)
downloadmariadb-git-7735a2f2ebe54e6df926097b6c43d2aaba5fbcc5.tar.gz
Bug #29469: Client dies if a query is issued after hitting Ctrl + C
The Ctrl-C handler in mysql closes the console while ReadConsole() waits for console input. But the main thread was detecting that ReadConsole() haven't read anything and was processing as if there're data in the buffer. Fixed to handle correctly this error condition. No test case added as the test relies on Ctrl-C sent to the client from its console.
Diffstat (limited to 'mysys')
-rw-r--r--mysys/my_conio.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/mysys/my_conio.c b/mysys/my_conio.c
index 23b0c55e7a9..def15674f26 100644
--- a/mysys/my_conio.c
+++ b/mysys/my_conio.c
@@ -184,16 +184,19 @@ char* my_cgets(char *buffer, unsigned long clen, unsigned long* plen)
}
while (GetLastError() == ERROR_NOT_ENOUGH_MEMORY);
+ /* We go here on error reading the string (Ctrl-C for example) */
+ if (!*plen)
+ result= NULL; /* purecov: inspected */
if (result != NULL)
{
- if (buffer[*plen - 2] == '\r')
+ if (*plen > 1 && buffer[*plen - 2] == '\r')
{
*plen= *plen - 2;
}
else
{
- if (buffer[*plen - 1] == '\r')
+ if (*plen > 0 && buffer[*plen - 1] == '\r')
{
char tmp[3];
int tmplen= sizeof(tmp);