Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.

This commit is contained in:
Enno Rehling 2018-02-25 18:14:48 +01:00
parent 13cc8841d3
commit 120b03d2f5
4 changed files with 12 additions and 12 deletions

View file

@ -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); log_warning("trying to create message of unknown type \"%s\"\n", name);
if (!mt_find("missing_feedback")) { if (!mt_find("missing_feedback")) {
mt_register(mt_new_va("missing_feedback", "unit:unit", 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", return msg_message("missing_feedback", "name unit region command",
name, u, u->region, ord); name, u, u->region, ord);

View file

@ -12,7 +12,7 @@ void test_missing_message(CuTest *tc) {
test_setup(); test_setup();
message_handle_missing(MESSAGE_MISSING_REPLACE); 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);
CuAssertPtrNotNull(tc, msg->type); CuAssertPtrNotNull(tc, msg->type);
CuAssertStrEquals(tc, msg->type->name, "missing_message"); CuAssertStrEquals(tc, msg->type->name, "missing_message");

View file

@ -838,7 +838,7 @@ static int sp_magicstreet(castorder * co)
/* melden, 1x pro Partei */ /* melden, 1x pro Partei */
{ {
message *seen = msg_message("path_effect", "mage region", mage, r); 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); report_effect(r, mage, seen, unseen);
msg_release(seen); msg_release(seen);
msg_release(unseen); msg_release(unseen);
@ -895,7 +895,7 @@ static int sp_summonent(castorder * co)
/* melden, 1x pro Partei */ /* melden, 1x pro Partei */
{ {
message *seen = msg_message("ent_effect", "mage amount", mage, ents); 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); report_effect(r, mage, seen, unseen);
msg_release(unseen); msg_release(unseen);
msg_release(seen); msg_release(seen);
@ -989,7 +989,7 @@ static int sp_maelstrom(castorder * co)
/* melden, 1x pro Partei */ /* melden, 1x pro Partei */
if (c) { if (c) {
message *seen = msg_message("maelstrom_effect", "mage", mage); 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); report_effect(r, mage, seen, unseen);
msg_release(seen); msg_release(seen);
msg_release(unseen); msg_release(unseen);
@ -1033,7 +1033,7 @@ static int sp_mallorn(castorder * co)
/* melden, 1x pro Partei */ /* melden, 1x pro Partei */
{ {
message *seen = msg_message("mallorn_effect", "mage", mage); 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); report_effect(r, mage, seen, unseen);
msg_release(seen); msg_release(seen);
msg_release(unseen); msg_release(unseen);
@ -1068,7 +1068,7 @@ static int sp_blessedharvest(castorder * co)
duration, 1.0, 0)) { duration, 1.0, 0)) {
const char * effect = co->sp->sname[0]=='b' ? "harvest_effect" : "raindance_effect"; const char * effect = co->sp->sname[0]=='b' ? "harvest_effect" : "raindance_effect";
message *seen = msg_message(effect, "mage", mage); 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); report_effect(r, mage, seen, unseen);
msg_release(seen); msg_release(seen);
msg_release(unseen); msg_release(unseen);
@ -1114,7 +1114,7 @@ static int sp_hain(castorder * co)
{ {
message *seen = msg_message("growtree_effect", "mage amount", mage, trees); message *seen = msg_message("growtree_effect", "mage amount", mage, trees);
message *unseen = 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); report_effect(r, mage, seen, unseen);
msg_release(seen); msg_release(seen);
msg_release(unseen); msg_release(unseen);
@ -1160,7 +1160,7 @@ static int sp_mallornhain(castorder * co)
{ {
message *seen = msg_message("growtree_effect", "mage amount", mage, trees); message *seen = msg_message("growtree_effect", "mage amount", mage, trees);
message *unseen = 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); report_effect(r, mage, seen, unseen);
msg_release(seen); msg_release(seen);
msg_release(unseen); msg_release(unseen);
@ -2675,7 +2675,7 @@ static int sp_firewall(castorder * co)
/* melden, 1x pro Partei */ /* melden, 1x pro Partei */
{ {
message *seen = msg_message("firewall_effect", "mage region", mage, r); 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); report_effect(r, mage, seen, unseen);
msg_release(seen); msg_release(seen);
msg_release(unseen); msg_release(unseen);
@ -4368,7 +4368,7 @@ int sp_puttorest(castorder * co)
int dead = deathcount(r); int dead = deathcount(r);
int laid_to_rest = dice((int)(co->force * 2), 100); int laid_to_rest = dice((int)(co->force * 2), 100);
message *seen = msg_message("puttorest", "mage", mage); 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; if (laid_to_rest < dead) laid_to_rest = dead;

View file

@ -466,7 +466,7 @@ static void sink_ship(region * r, ship * sh, unit * saboteur)
move_unit(u, safety, NULL); move_unit(u, safety, NULL);
} }
else { 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); add_message(&u->faction->msgs, msg);
msg_release(msg); msg_release(msg);