We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c661592 commit d0c636bCopy full SHA for d0c636b
core/shared/mem-alloc/ems/ems_gc_internal.h
@@ -338,8 +338,13 @@ typedef struct gc_heap_struct {
338
static inline void
339
gc_update_threshold(gc_heap_t *heap)
340
{
341
- heap->gc_threshold =
342
- heap->total_free_size * heap->gc_threshold_factor / 1000;
+ uint64_t result = (uint64_t)heap->total_free_size
+ * (uint64_t)heap->gc_threshold_factor / 1000;
343
+ /* heap->total_free_size * heap->gc_threshold_factor won't exceed
344
+ * 6^32(GC_HEAP_SIZE_MAX * GC_DEFAULT_THRESHOLD_FACTOR), so casting result
345
+ * to uint32_t is safe
346
+ */
347
+ heap->gc_threshold = (uint32_t)result;
348
}
349
350
#define gct_vm_mutex_init os_mutex_init
0 commit comments