Spot the bug in array-copy allocation

from C dynamic memory management
C23 (GCC 13.3.0) intermediate 4 min 1 issue to find

Find the size bug in this generated array-copy function.

C
#include <stddef.h>
#include <stdlib.h>

int *copy_readings(const int *source, size_t count) {
    int *copy = (int *)malloc(count * sizeof *copy);
    if (copy == NULL) {
        return NULL;
    }
    for (size_t index = 0; index < count; ++index) {
        copy[index] = source[index];
    }
    return copy;
}
Open in playground
Report an error