Remove multiplication from second argument to Memory_safeMalloc().
authorTilman Sauerbeck <tilman@code-monkey.de>
Wed, 27 Dec 2017 15:13:46 +0000 (16:13 +0100)
committerTilman Sauerbeck <tilman@code-monkey.de>
Wed, 27 Dec 2017 15:13:46 +0000 (16:13 +0100)
In Msg_banList_create(), transform
  Memory_safeMalloc(1, sizeof(foo) * many)
to
  Memory_safeMalloc(many, sizeof(foo))
to actually make use of Memory_safeMalloc()'s overflow detection.

src/messages.c

index d99548563c042cb04e417930ece49d2a6cc9db59..36bd20ccd6c236ec5dc8f4c146eefec3648e59ca 100644 (file)
@@ -384,7 +384,7 @@ message_t *Msg_banList_create(int n_bans)
        msg->payload.banList = Memory_safeCalloc(1, sizeof(MumbleProto__BanList));
        mumble_proto__ban_list__init(msg->payload.banList);
        msg->payload.banList->n_bans = n_bans;
-       msg->payload.banList->bans = Memory_safeMalloc(1, sizeof(MumbleProto__BanList__BanEntry *) * n_bans);
+       msg->payload.banList->bans = Memory_safeMalloc(n_bans, sizeof(MumbleProto__BanList__BanEntry *));
        for (i = 0; i < n_bans; i++) {
                msg->payload.banList->bans[i] = Memory_safeCalloc(1, sizeof(MumbleProto__BanList__BanEntry));
                mumble_proto__ban_list__ban_entry__init(msg->payload.banList->bans[i]);