Index: src/runtime/runtime-collections.cc |
diff --git a/src/runtime/runtime-collections.cc b/src/runtime/runtime-collections.cc |
index e6a86d114a7f8d04828f0c049deaa93bc3c14491..abdd056998e70f5903d887789f9a4ca40b2258a4 100644 |
--- a/src/runtime/runtime-collections.cc |
+++ b/src/runtime/runtime-collections.cc |
@@ -394,6 +394,10 @@ RUNTIME_FUNCTION(Runtime_GetWeakSetValues) { |
max_values = table->NumberOfElements(); |
} |
Handle<FixedArray> values = isolate->factory()->NewFixedArray(max_values); |
+ // Recompute max_values because GC could have removed elements from the table. |
+ if (max_values > table->NumberOfElements()) { |
+ max_values = table->NumberOfElements(); |
+ } |
{ |
DisallowHeapAllocation no_gc; |
int count = 0; |