Navigation Menu

Skip to content

Commit

Permalink
mysql57: follow THD::db type change
Browse files Browse the repository at this point in the history
I don't know whether THD::db() (LEX_CSTRING) is NULL
terminated. Generally, LEX_CSTRING isn't NULL terminated.

If THD::db() isn't NULL terminated, Mroonga may crash.
  • Loading branch information
kou committed Mar 14, 2015
1 parent e22487b commit 4a3a874
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion mrn_mysql_compat.h
@@ -1,6 +1,6 @@
/* -*- c-basic-offset: 2 -*- */
/*
Copyright(C) 2011-2014 Kouhei Sutou <kou@clear-code.com>
Copyright(C) 2011-2015 Kouhei Sutou <kou@clear-code.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -158,4 +158,10 @@
# define MRN_STRING_FREE(string) string.free();
#endif

#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
# define MRN_THD_DB_PATH(thd) ((thd)->db().str)
#else
# define MRN_THD_DB_PATH(thd) ((thd)->db)
#endif

#endif /* MRN_MYSQL_COMPAT_H_ */
2 changes: 1 addition & 1 deletion udf/mrn_udf_command.cpp
Expand Up @@ -68,7 +68,7 @@ MRN_API my_bool mroonga_command_init(UDF_INIT *initid, UDF_ARGS *args,

grn_ctx_init(&(info->ctx), 0);
{
const char *current_db_path = current_thd->db;
const char *current_db_path = MRN_THD_DB_PATH(current_thd);
const char *action;
if (current_db_path) {
action = "open database";
Expand Down

0 comments on commit 4a3a874

Please sign in to comment.