mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 07:33:01 +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:
		| @@ -32,7 +32,7 @@ | ||||
|  | ||||
| static void *janet_memalloc_empty_local(int32_t count) { | ||||
|     int32_t i; | ||||
|     void *mem = janet_smalloc(count * sizeof(JanetKV)); | ||||
|     void *mem = janet_smalloc((size_t) count * sizeof(JanetKV)); | ||||
|     JanetKV *mmem = (JanetKV *)mem; | ||||
|     for (i = 0; i < count; i++) { | ||||
|         JanetKV *kv = mmem + i; | ||||
| @@ -241,7 +241,7 @@ JanetTable *janet_table_clone(JanetTable *table) { | ||||
|     if (NULL == newTable->data) { | ||||
|         JANET_OUT_OF_MEMORY; | ||||
|     } | ||||
|     memcpy(newTable->data, table->data, table->capacity * sizeof(JanetKV)); | ||||
|     memcpy(newTable->data, table->data, (size_t) table->capacity * sizeof(JanetKV)); | ||||
|     return newTable; | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose