From 9bc5014787bdb77f11d7532e1bb2870608c6d638 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sat, 18 Jan 2020 10:44:16 -0800 Subject: [PATCH] CARD: Avoid potential truncation warnings when allocating the deck buffer Card decks will never be excessively large (> uint32) since there never was a computer room big enough to hold that many cards. :-) Hopper counts and size are all of type t_addr since they are referenced relative to uptr->pos which tracks the hopper position. That state is managed so position is properly managed across a SAVE/RESTORE. On some systems that use sim_card, t_addr is 64bits, hence --- sim_card.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sim_card.c b/sim_card.c index e6618c02..fc75797a 100644 --- a/sim_card.c +++ b/sim_card.c @@ -931,9 +931,9 @@ _sim_read_deck(UNIT * uptr, int eof) if (data->hopper_cards >= data->hopper_size) { data->hopper_size += DECK_SIZE; data->images = (uint16 (*)[1][80])realloc(data->images, - data->hopper_size * sizeof(*(data->images))); + (size_t)data->hopper_size * sizeof(*(data->images))); memset(&data->images[data->hopper_cards], 0, - (data->hopper_size - data->hopper_cards) * + (size_t)(data->hopper_size - data->hopper_cards) * sizeof(*(data->images))); } @@ -961,9 +961,9 @@ _sim_read_deck(UNIT * uptr, int eof) if (data->hopper_cards >= data->hopper_size) { data->hopper_size += DECK_SIZE; data->images = (uint16 (*)[1][80])realloc(data->images, - data->hopper_size * sizeof(*(data->images))); + (size_t)data->hopper_size * sizeof(*(data->images))); memset(&data->images[data->hopper_cards], 0, - (data->hopper_size - data->hopper_cards) * + (size_t)(data->hopper_size - data->hopper_cards) * sizeof(*(data->images))); }