mirror of
https://github.com/janet-lang/janet
synced 2025-11-15 06:47:17 +00:00
Fix some issues found with -fsanitize=undefined
Leave in issues with calling memcpy with size=0. If these become a problem, will probably add a janet_memcpy as memcpy is used so much in the code without 0 checks.
This commit is contained in:
@@ -66,12 +66,16 @@ void janetc_regalloc_clone(JanetcRegisterAllocator *dest, JanetcRegisterAllocato
|
||||
dest->capacity = src->capacity;
|
||||
dest->max = src->max;
|
||||
size = sizeof(uint32_t) * dest->capacity;
|
||||
dest->chunks = malloc(size);
|
||||
dest->regtemps = 0;
|
||||
if (!dest->chunks) {
|
||||
JANET_OUT_OF_MEMORY;
|
||||
if (size) {
|
||||
dest->chunks = malloc(size);
|
||||
if (!dest->chunks) {
|
||||
JANET_OUT_OF_MEMORY;
|
||||
}
|
||||
memcpy(dest->chunks, src->chunks, size);
|
||||
} else {
|
||||
dest->chunks = NULL;
|
||||
}
|
||||
memcpy(dest->chunks, src->chunks, size);
|
||||
}
|
||||
|
||||
/* Allocate one more chunk in chunks */
|
||||
|
||||
Reference in New Issue
Block a user