summaryrefslogtreecommitdiff
path: root/include/m_string.h
diff options
context:
space:
mode:
authorRucha Deodhar <rucha.deodhar@mariadb.com>2020-06-24 13:59:26 +0530
committerRucha Deodhar <rucha.deodhar@mariadb.com>2020-06-24 15:14:25 +0530
commit4c2cde1bef1533dd989cb6a37c482c3437d66403 (patch)
tree743e9cf69fd224d89ff5541ceee6e51378b50233 /include/m_string.h
parenteba918977793f0995d2f4f7707fc5dd891da4064 (diff)
downloadmariadb-git-bb-10.2-MDEV-20643.tar.gz
MDEV-20643: Server crashes in find_table_in_list upon INSERT .. SELECT after dropping a databasebb-10.2-MDEV-20643
table->db is NULL, so strcmp() in find_tables_in_list() gets NULL in the argument. So it crashes. Fix: Using a safe_strcmp() function which compares two strings if they are not null otherwise uses safe_str() to convert the NULL string into empty string before comparing them.
Diffstat (limited to 'include/m_string.h')
-rw-r--r--include/m_string.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/m_string.h b/include/m_string.h
index 2f609d5e29f..864962735f3 100644
--- a/include/m_string.h
+++ b/include/m_string.h
@@ -232,6 +232,10 @@ static inline char *safe_str(char *str)
static inline const char *safe_str(const char *str)
{ return str ? str : ""; }
+static inline int safe_strcmp(char *str1, const char *str2)
+{ return ((str1 && str2) ? strcmp(str1, str2) :
+ strcmp(safe_str(str1), safe_str(str2))); }
+
static inline size_t safe_strlen(const char *str)
{ return str ? strlen(str) : 0; }