From 26d0623d07e29109f39cd04dfa2e5534bf7d5be3 Mon Sep 17 00:00:00 2001 From: dongresource Date: Sat, 19 Dec 2020 05:48:18 +0100 Subject: [PATCH] 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. --- src/Database.cpp | 16 ++++++++-------- tdata | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Database.cpp b/src/Database.cpp index ed7cd17..85bebc0 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -1836,17 +1836,17 @@ bool Database::sendEmail(EmailData* data, std::vector attachments) { sqlite3_finalize(stmt); + sql = R"( + INSERT INTO EmailItems + (PlayerID, MsgIndex, Slot, ID, Type, Opt, TimeLimit) + VALUES (?, ?, ?, ?, ?, ?, ?); + )"; + + sqlite3_prepare_v2(db, sql, -1, &stmt, NULL); + // 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); sqlite3_bind_int(stmt, 1, data->PlayerId); sqlite3_bind_int(stmt, 2, data->MsgIndex); sqlite3_bind_int(stmt, 3, slot++); diff --git a/tdata b/tdata index a6a3841..75d82f3 160000 --- a/tdata +++ b/tdata @@ -1 +1 @@ -Subproject commit a6a3841ff219ed57bbfda008782220ac4c111664 +Subproject commit 75d82f3155687d73ad72cfc479d2c2c7c3ecd20f