From 053143efe1a78184c3dc5e6c20f6f4c59491cb7e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 25 Apr 2015 21:56:46 +0200 Subject: [PATCH] MDEV-7883 Segmentation failure when running mysqladmin -u root -p take into account that argc can be 0 (if there were no commands on the command line) --- client/mysqladmin.cc | 3 +++ mysql-test/t/mysqladmin.test | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 57feed163ad..10026cfaacf 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -1198,6 +1198,9 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) static char **mask_password(int argc, char ***argv) { char **temp_argv; + if (!argc) + return NULL; + temp_argv= (char **)(my_malloc(sizeof(char *) * argc, MYF(MY_WME))); argc--; while (argc > 0) diff --git a/mysql-test/t/mysqladmin.test b/mysql-test/t/mysqladmin.test index c04c8d50f3c..2580db88456 100644 --- a/mysql-test/t/mysqladmin.test +++ b/mysql-test/t/mysqladmin.test @@ -45,3 +45,9 @@ EOF --exec $MYSQLADMIN --defaults-extra-file=$MYSQLTEST_VARDIR/tmp/cnf_file -uroot -S $MASTER_MYSOCK -P $MASTER_MYPORT ping 2>&1 --remove_file $MYSQLTEST_VARDIR/tmp/cnf_file + +# +# MDEV-7883 Segmentation failure when running mysqladmin -u root -p +# +--error 1 +--exec $MYSQLADMIN -u root -p 2>&1 > /dev/null