mirror of
				https://github.com/janet-lang/janet
				synced 2025-11-04 09:33:02 +00:00 
			
		
		
		
	Try to remove potential overflow bugs.
Also make integer to size_t casts explicit rather than relying on int32_t * sizeof(x) = size_t. This is kind of a personal preference for this problem.
This commit is contained in:
		@@ -162,8 +162,8 @@ Janet(janet_wrap_number)(double x) {
 | 
			
		||||
 | 
			
		||||
void *janet_memalloc_empty(int32_t count) {
 | 
			
		||||
    int32_t i;
 | 
			
		||||
    void *mem = malloc(count * sizeof(JanetKV));
 | 
			
		||||
    janet_vm_next_collection += count * sizeof(JanetKV);
 | 
			
		||||
    void *mem = malloc((size_t) count * sizeof(JanetKV));
 | 
			
		||||
    janet_vm_next_collection += (size_t) count * sizeof(JanetKV);
 | 
			
		||||
    if (NULL == mem) {
 | 
			
		||||
        JANET_OUT_OF_MEMORY;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user