diff --git a/client/maxadmin.c b/client/maxadmin.c index 5710cc35a..683916e9f 100644 --- a/client/maxadmin.c +++ b/client/maxadmin.c @@ -58,6 +58,7 @@ static int authMaxScale(int so, char *user, char *password); static int sendCommand(int so, char *cmd); static void DoSource(int so, char *cmd); static void DoUsage(); +static int isquit(char *buf); #ifdef HISTORY static char * @@ -289,7 +290,7 @@ int argno = 0; history(hist, &ev, H_ENTER, buf); #endif - if (!strcasecmp(buf, "quit")) + if (isquit(buf)) { break; } @@ -552,3 +553,23 @@ DoUsage() printf("Any remaining arguments are treated as MaxScale commands or a file\n"); printf("containing commands to execute.\n"); } + +/** + * Check command to see if it is a quit command + * + * @param buf The command buffer + * @return Non-zero if the command should cause maxadmin to quit + */ +static int +isquit(char *buf) +{ +char *ptr = buf; + + if (!buf) + return 0; + while (*ptr && isspace(*ptr)) + ptr++; + if (strncasecmp(ptr, "quit", 4) == 0 || strncasecmp(ptr, "exit", 4) == 0) + return 1; + return 0; +} diff --git a/server/core/session.c b/server/core/session.c index a67926b48..eb9d42a2b 100644 --- a/server/core/session.c +++ b/server/core/session.c @@ -693,8 +693,17 @@ int i; service->name))); return 0; } - session->tail = *tail; - free(tail); + + /* + * filterUpstream may simply return the 3 parameter if + * the filter has no upstream entry point. So no need + * to copy the contents or free tail in this case. + */ + if (tail != &session->tail) + { + session->tail = *tail; + free(tail); + } } return 1;