
If a size parameter is stored in variables of type size_t, but operated on in such a way that it is temporarily stored in a variable that is not of type size_t, then the original value of the size may be truncated. When this value is passed to malloc, calloc, or realloc, a block of memory with an unexpected size may be allocated.
To prevent this error, size parameters should not be operated on in a way that they are stored in different data types
h2 Non-compliant code example
h2 compliant solution