mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-19 09:25:08 -04:00
memcpy(x, NULL, 0) is undefined behavior
This commit is contained in:
parent
3d8ff446ad
commit
b35c418558
7 changed files with 31 additions and 13 deletions
|
@ -61,13 +61,15 @@ void randomcache_refill(void) {
|
|||
|
||||
void randomcache_getbytes(void *dst, size_t num_bytes) {
|
||||
unsigned int low = g_random_cache_low;
|
||||
|
||||
if (num_bytes == 0) {
|
||||
return;
|
||||
}
|
||||
memcpy(dst, &g_random_cache[low], num_bytes);
|
||||
|
||||
unsigned int new_low = low + num_bytes;
|
||||
if (new_low + 0x38 > 0x3FF) {
|
||||
new_low = 0;
|
||||
}
|
||||
|
||||
|
||||
g_random_cache_low = new_low;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue