Commit a1e56938 authored by Vivien Kraus's avatar Vivien Kraus
Browse files

Silence ubsan

parent 891ee8db
...@@ -31,7 +31,10 @@ event_size (size_t n_data) ...@@ -31,7 +31,10 @@ event_size (size_t n_data)
static inline void static inline void
event_copy_data (TarotGameEvent * event, size_t n, const unsigned int *data) event_copy_data (TarotGameEvent * event, size_t n, const unsigned int *data)
{ {
memcpy (event->data, data, n * sizeof (*data)); if (n != 0)
{
memcpy (event->data, data, n * sizeof (*data));
}
event->n = n; event->n = n;
} }
...@@ -416,7 +419,10 @@ event_get_data (const TarotGameEvent * event, size_t *n, size_t start, ...@@ -416,7 +419,10 @@ event_get_data (const TarotGameEvent * event, size_t *n, size_t start,
{ {
max = event->n; max = event->n;
} }
memcpy (cards, event->data + start, max * sizeof (*cards)); if (max != 0)
{
memcpy (cards, event->data + start, max * sizeof (*cards));
}
} }
static inline TarotGameEventError static inline TarotGameEventError
......
...@@ -680,7 +680,10 @@ query_hand (const TarotHand * hand, size_t *n, size_t start, size_t max, ...@@ -680,7 +680,10 @@ query_hand (const TarotHand * hand, size_t *n, size_t start, size_t max,
} }
*n = n_available; *n = n_available;
assert (start + max <= n_available); assert (start + max <= n_available);
memcpy (dest, hand->buffer + start, max * sizeof (TarotCard)); if (max != 0)
{
memcpy (dest, hand->buffer + start, max * sizeof (TarotCard));
}
} }
static inline TarotGameError static inline TarotGameError
...@@ -774,7 +777,10 @@ game_get_bids (const TarotGame * game, size_t *n, TarotPlayer start, ...@@ -774,7 +777,10 @@ game_get_bids (const TarotGame * game, size_t *n, TarotPlayer start,
{ {
max = *n - start; max = *n - start;
} }
memcpy (bids, h.bids->bids + start, max * sizeof (TarotBid)); if (max != 0)
{
memcpy (bids, h.bids->bids + start, max * sizeof (TarotBid));
}
ret = TAROT_GAME_OK; ret = TAROT_GAME_OK;
} }
return ret; return ret;
...@@ -2403,7 +2409,10 @@ game_can_autoreveal (const TarotGame * game, size_t *n_dog, size_t start, ...@@ -2403,7 +2409,10 @@ game_can_autoreveal (const TarotGame * game, size_t *n_dog, size_t start,
{ {
max = n - start; max = n - start;
} }
memcpy (dog, buffer + start, max * sizeof (TarotCard)); if (max != 0)
{
memcpy (dog, buffer + start, max * sizeof (TarotCard));
}
return ret; return ret;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment