summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2020-06-01 19:30:56 +0200
committerGitHub <noreply@github.com>2020-06-01 19:30:56 +0200
commit2b700485468b60f60b72f11f3b63fee473cf4c87 (patch)
tree4f7d699489a1fb1f01b8e7e7ea6b90a861c02af9 /src/plugins
parentfc97482358b89dbba281f8e620d7fcc09d189d32 (diff)
parent2ed87967d020c931c14ca0cea173eeba479bb886 (diff)
downloadhercules-2b700485468b60f60b72f11f3b63fee473cf4c87.tar.gz
hercules-2b700485468b60f60b72f11f3b63fee473cf4c87.tar.bz2
hercules-2b700485468b60f60b72f11f3b63fee473cf4c87.tar.xz
hercules-2b700485468b60f60b72f11f3b63fee473cf4c87.zip
Merge pull request #2748 from 4144/db2sql
Fix db2sql crash with mariadb client library
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/db2sql.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c
index 6ca52a593..8d83c25e2 100644
--- a/src/plugins/db2sql.c
+++ b/src/plugins/db2sql.c
@@ -65,6 +65,8 @@ struct {
bool itemdb2sql_torun = false;
/// Whether the mob_db converter will automatically run.
bool mobdb2sql_torun = false;
+/// mysql handle for escape strings
+static struct Sql *sql_handle = NULL;
/// Backup of the original item_db parser function pointer.
int (*itemdb_readdb_libconfig_sub) (struct config_setting_t *it, int n, const char *source);
@@ -249,11 +251,11 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source)
StrBuf->Printf(&buf, "'%u',", (uint32)it->nameid);
// name_english
- SQL->EscapeString(NULL, e_name, it->name);
+ SQL->EscapeString(sql_handle, e_name, it->name);
StrBuf->Printf(&buf, "'%s',", e_name);
// name_japanese
- SQL->EscapeString(NULL, e_name, it->jname);
+ SQL->EscapeString(sql_handle, e_name, it->jname);
StrBuf->Printf(&buf, "'%s',", e_name);
// type
@@ -397,7 +399,7 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source)
tosql.buf[0].len = tosql.buf[0].len + strlen(str) + 1000;
RECREATE(tosql.buf[0].p,char,tosql.buf[0].len);
}
- SQL->EscapeString(NULL, tosql.buf[0].p, str);
+ SQL->EscapeString(sql_handle, tosql.buf[0].p, str);
StrBuf->Printf(&buf, "'%s',", tosql.buf[0].p);
} else {
StrBuf->AppendStr(&buf, "'',");
@@ -411,7 +413,7 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source)
tosql.buf[1].len = tosql.buf[1].len + strlen(str) + 1000;
RECREATE(tosql.buf[1].p,char,tosql.buf[1].len);
}
- SQL->EscapeString(NULL, tosql.buf[1].p, str);
+ SQL->EscapeString(sql_handle, tosql.buf[1].p, str);
StrBuf->Printf(&buf, "'%s',", tosql.buf[1].p);
} else {
StrBuf->AppendStr(&buf, "'',");
@@ -425,7 +427,7 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source)
tosql.buf[2].len = tosql.buf[2].len + strlen(str) + 1000;
RECREATE(tosql.buf[2].p,char,tosql.buf[2].len);
}
- SQL->EscapeString(NULL, tosql.buf[2].p, str);
+ SQL->EscapeString(sql_handle, tosql.buf[2].p, str);
StrBuf->Printf(&buf, "'%s'", tosql.buf[2].p);
} else {
StrBuf->AppendStr(&buf, "''");
@@ -563,15 +565,15 @@ int mobdb2sql_sub(struct config_setting_t *mobt, int n, const char *source)
StrBuf->Printf(&buf, "%d,", md->mob_id);
// Sprite
- SQL->EscapeString(NULL, e_name, md->sprite);
+ SQL->EscapeString(sql_handle, e_name, md->sprite);
StrBuf->Printf(&buf, "'%s',", e_name);
// kName
- SQL->EscapeString(NULL, e_name, md->name);
+ SQL->EscapeString(sql_handle, e_name, md->name);
StrBuf->Printf(&buf, "'%s',", e_name);
// iName
- SQL->EscapeString(NULL, e_name, md->jname);
+ SQL->EscapeString(sql_handle, e_name, md->jname);
StrBuf->Printf(&buf, "'%s',", e_name);
// LV
@@ -967,7 +969,7 @@ bool mobskilldb2sql_sub(struct config_setting_t *it, int n, int mob_id)
StrBuf->Printf(&buf, "%d,", mob_id);
// Info
- SQL->EscapeString(NULL, e_name, md->name);
+ SQL->EscapeString(sql_handle, e_name, md->name);
StrBuf->Printf(&buf, "'%s@%s',", e_name, name);
if (mob->lookup_const(it, "SkillState", &i32) && (i32 < MSS_ANY || i32 > MSS_ANYTARGET)) {
@@ -1215,8 +1217,15 @@ HPExport void plugin_init(void)
HPExport void server_online(void)
{
+ sql_handle = SQL->Malloc();
if (itemdb2sql_torun)
do_itemdb2sql();
if (mobdb2sql_torun)
do_mobdb2sql();
}
+
+HPExport void plugin_final (void)
+{
+ SQL->Free(sql_handle);
+ sql_handle = NULL;
+}