From 120b03d2f59cefd4ba3c02979d367770ea27c120 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 25 Feb 2018 18:14:48 +0100 Subject: [PATCH] Passing NULL after the last typed argument to a variadic function leads to undefined behaviour. --- src/kernel/messages.c | 2 +- src/kernel/messages.test.c | 2 +- src/spells.c | 18 +++++++++--------- src/spy.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/kernel/messages.c b/src/kernel/messages.c index 7b9040745..9875d303e 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -83,7 +83,7 @@ struct message *msg_feedback(const struct unit *u, struct order *ord, log_warning("trying to create message of unknown type \"%s\"\n", name); if (!mt_find("missing_feedback")) { mt_register(mt_new_va("missing_feedback", "unit:unit", - "region:region", "command:order", "name:string", NULL)); + "region:region", "command:order", "name:string", MT_NEW_END)); } return msg_message("missing_feedback", "name unit region command", name, u, u->region, ord); diff --git a/src/kernel/messages.test.c b/src/kernel/messages.test.c index 4afe25518..ad6a08071 100644 --- a/src/kernel/messages.test.c +++ b/src/kernel/messages.test.c @@ -12,7 +12,7 @@ void test_missing_message(CuTest *tc) { test_setup(); message_handle_missing(MESSAGE_MISSING_REPLACE); - msg = msg_message("unknown", "unit", NULL); + msg = msg_message("unknown", "unit", (unit *)NULL); CuAssertPtrNotNull(tc, msg); CuAssertPtrNotNull(tc, msg->type); CuAssertStrEquals(tc, msg->type->name, "missing_message"); diff --git a/src/spells.c b/src/spells.c index 8334d19c0..7bab3fd2e 100644 --- a/src/spells.c +++ b/src/spells.c @@ -838,7 +838,7 @@ static int sp_magicstreet(castorder * co) /* melden, 1x pro Partei */ { message *seen = msg_message("path_effect", "mage region", mage, r); - message *unseen = msg_message("path_effect", "mage region", NULL, r); + message *unseen = msg_message("path_effect", "mage region", (unit *)NULL, r); report_effect(r, mage, seen, unseen); msg_release(seen); msg_release(unseen); @@ -895,7 +895,7 @@ static int sp_summonent(castorder * co) /* melden, 1x pro Partei */ { message *seen = msg_message("ent_effect", "mage amount", mage, ents); - message *unseen = msg_message("ent_effect", "mage amount", NULL, ents); + message *unseen = msg_message("ent_effect", "mage amount", (unit *)NULL, ents); report_effect(r, mage, seen, unseen); msg_release(unseen); msg_release(seen); @@ -989,7 +989,7 @@ static int sp_maelstrom(castorder * co) /* melden, 1x pro Partei */ if (c) { message *seen = msg_message("maelstrom_effect", "mage", mage); - message *unseen = msg_message("maelstrom_effect", "mage", NULL); + message *unseen = msg_message("maelstrom_effect", "mage", (unit *)NULL); report_effect(r, mage, seen, unseen); msg_release(seen); msg_release(unseen); @@ -1033,7 +1033,7 @@ static int sp_mallorn(castorder * co) /* melden, 1x pro Partei */ { message *seen = msg_message("mallorn_effect", "mage", mage); - message *unseen = msg_message("mallorn_effect", "mage", NULL); + message *unseen = msg_message("mallorn_effect", "mage", (unit *)NULL); report_effect(r, mage, seen, unseen); msg_release(seen); msg_release(unseen); @@ -1068,7 +1068,7 @@ static int sp_blessedharvest(castorder * co) duration, 1.0, 0)) { const char * effect = co->sp->sname[0]=='b' ? "harvest_effect" : "raindance_effect"; message *seen = msg_message(effect, "mage", mage); - message *unseen = msg_message(effect, "mage", NULL); + message *unseen = msg_message(effect, "mage", (unit *)NULL); report_effect(r, mage, seen, unseen); msg_release(seen); msg_release(unseen); @@ -1114,7 +1114,7 @@ static int sp_hain(castorder * co) { message *seen = msg_message("growtree_effect", "mage amount", mage, trees); message *unseen = - msg_message("growtree_effect", "mage amount", NULL, trees); + msg_message("growtree_effect", "mage amount", (unit *)NULL, trees); report_effect(r, mage, seen, unseen); msg_release(seen); msg_release(unseen); @@ -1160,7 +1160,7 @@ static int sp_mallornhain(castorder * co) { message *seen = msg_message("growtree_effect", "mage amount", mage, trees); message *unseen = - msg_message("growtree_effect", "mage amount", NULL, trees); + msg_message("growtree_effect", "mage amount", (unit *)NULL, trees); report_effect(r, mage, seen, unseen); msg_release(seen); msg_release(unseen); @@ -2675,7 +2675,7 @@ static int sp_firewall(castorder * co) /* melden, 1x pro Partei */ { message *seen = msg_message("firewall_effect", "mage region", mage, r); - message *unseen = msg_message("firewall_effect", "mage region", NULL, r); + message *unseen = msg_message("firewall_effect", "mage region", (unit *)NULL, r); report_effect(r, mage, seen, unseen); msg_release(seen); msg_release(unseen); @@ -4368,7 +4368,7 @@ int sp_puttorest(castorder * co) int dead = deathcount(r); int laid_to_rest = dice((int)(co->force * 2), 100); message *seen = msg_message("puttorest", "mage", mage); - message *unseen = msg_message("puttorest", "mage", NULL); + message *unseen = msg_message("puttorest", "mage", (unit *)NULL); if (laid_to_rest < dead) laid_to_rest = dead; diff --git a/src/spy.c b/src/spy.c index 8d9d4fe8c..94d6c4e7d 100644 --- a/src/spy.c +++ b/src/spy.c @@ -466,7 +466,7 @@ static void sink_ship(region * r, ship * sh, unit * saboteur) move_unit(u, safety, NULL); } else { - msg = msg_message("sink_lost_msg", "dead region unit", dead, NULL, u); + msg = msg_message("sink_lost_msg", "dead region unit", dead, (region *)NULL, u); } add_message(&u->faction->msgs, msg); msg_release(msg);