summaryrefslogtreecommitdiff
path: root/src/char/int_quest.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2017-09-17 19:32:57 +0200
committerHaru <haru@dotalux.com>2017-11-18 19:25:36 +0100
commit6c31098eb0195c024f6eaf468ac918cc7ce37cf3 (patch)
treea38b4ecc291fe37a97f6f854ae241f32495711cb /src/char/int_quest.c
parenta63c82c8bd29fd829a5d8cfba7d02d11cf4634c5 (diff)
downloadhercules-6c31098eb0195c024f6eaf468ac918cc7ce37cf3.tar.gz
hercules-6c31098eb0195c024f6eaf468ac918cc7ce37cf3.tar.bz2
hercules-6c31098eb0195c024f6eaf468ac918cc7ce37cf3.tar.xz
hercules-6c31098eb0195c024f6eaf468ac918cc7ce37cf3.zip
Pass the correct types and sizes to the StmtBind functions
Fixes #1531 (and other similar issues) Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/char/int_quest.c')
-rw-r--r--src/char/int_quest.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/char/int_quest.c b/src/char/int_quest.c
index bd49cb7d4..9554be414 100644
--- a/src/char/int_quest.c
+++ b/src/char/int_quest.c
@@ -56,6 +56,7 @@ struct quest *mapif_quests_fromsql(int char_id, int *count)
StringBuf buf;
int i;
int sqlerror = SQL_SUCCESS;
+ int quest_state = 0;
if (!count)
return NULL;
@@ -77,11 +78,11 @@ struct quest *mapif_quests_fromsql(int char_id, int *count)
memset(&tmp_quest, 0, sizeof(struct quest));
if (SQL_ERROR == SQL->StmtPrepareStr(stmt, StrBuf->Value(&buf))
- || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, 0)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &char_id, sizeof char_id)
|| SQL_ERROR == SQL->StmtExecute(stmt)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_quest.quest_id, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &tmp_quest.state, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UINT, &tmp_quest.time, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &tmp_quest.quest_id, sizeof tmp_quest.quest_id, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 1, SQLDT_INT, &quest_state, sizeof quest_state, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 2, SQLDT_UINT, &tmp_quest.time, sizeof tmp_quest.time, NULL, NULL)
) {
sqlerror = SQL_ERROR;
}
@@ -89,7 +90,7 @@ struct quest *mapif_quests_fromsql(int char_id, int *count)
StrBuf->Destroy(&buf);
for (i = 0; sqlerror != SQL_ERROR && i < MAX_QUEST_OBJECTIVES; i++) { // Stop on the first error
- sqlerror = SQL->StmtBindColumn(stmt, 3+i, SQLDT_INT, &tmp_quest.count[i], 0, NULL, NULL);
+ sqlerror = SQL->StmtBindColumn(stmt, 3+i, SQLDT_INT, &tmp_quest.count[i], sizeof tmp_quest.count[i], NULL, NULL);
}
if (sqlerror == SQL_ERROR) {
@@ -105,9 +106,10 @@ struct quest *mapif_quests_fromsql(int char_id, int *count)
questlog = (struct quest *)aCalloc(*count, sizeof(struct quest));
while (SQL_SUCCESS == SQL->StmtNextRow(stmt)) {
+ tmp_quest.state = quest_state;
if (i >= *count) // Sanity check, should never happen
break;
- memcpy(&questlog[i++], &tmp_quest, sizeof(tmp_quest));
+ questlog[i++] = tmp_quest;
}
if (i < *count) {
// Should never happen. Compact array