Fix Database::sendEmail()

* Do not define an sqlite_stmt* named stmt in a loop such that it shadows
an outer variable of the same name.
* Do not re-prepare a statement that has been reset.
This commit is contained in:
dongresource 2020-12-19 05:48:18 +01:00
parent f8a359dfe9
commit 26d0623d07
2 changed files with 9 additions and 9 deletions

View File

@ -1836,17 +1836,17 @@ bool Database::sendEmail(EmailData* data, std::vector<sItemBase> attachments) {
sqlite3_finalize(stmt);
// send attachments
int slot = 1;
for (sItemBase item : attachments) {
sql = R"(
INSERT INTO EmailItems
(PlayerID, MsgIndex, Slot, ID, Type, Opt, TimeLimit)
VALUES (?, ?, ?, ?, ?, ?, ?);
)";
sqlite3_stmt* stmt;
sqlite3_prepare_v2(db, sql, -1, &stmt, NULL);
// send attachments
int slot = 1;
for (sItemBase item : attachments) {
sqlite3_bind_int(stmt, 1, data->PlayerId);
sqlite3_bind_int(stmt, 2, data->MsgIndex);
sqlite3_bind_int(stmt, 3, slot++);

2
tdata

@ -1 +1 @@
Subproject commit a6a3841ff219ed57bbfda008782220ac4c111664
Subproject commit 75d82f3155687d73ad72cfc479d2c2c7c3ecd20f