File tree 1 file changed +18
-17
lines changed
1 file changed +18
-17
lines changed Original file line number Diff line number Diff line change @@ -354,25 +354,26 @@ class HeapObjectPool : public internal::Statistics, public internal::PoolCommon<
354
354
if (object != nullptr )
355
355
{
356
356
internal::HeapObjectListNode * node = mObjects .FindNode (object);
357
- if (node != nullptr )
357
+ // Releasing an object that is not allocated indicates likely memory
358
+ // corruption; better to safe-crash than proceed at this point.
359
+ VerifyOrDie (node != nullptr );
360
+
361
+ node->mObject = nullptr ;
362
+ Platform::Delete (object);
363
+
364
+ // The node needs to be released immediately if we are not in the middle of iteration.
365
+ // Otherwise cleanup is deferred until all iteration on this pool completes and it's safe to release nodes.
366
+ if (mObjects .mIterationDepth == 0 )
358
367
{
359
- node->mObject = nullptr ;
360
- Platform::Delete (object);
361
-
362
- // The node needs to be released immediately if we are not in the middle of iteration.
363
- // Otherwise cleanup is deferred until all iteration on this pool completes and it's safe to release nodes.
364
- if (mObjects .mIterationDepth == 0 )
365
- {
366
- node->Remove ();
367
- Platform::Delete (node);
368
- }
369
- else
370
- {
371
- mObjects .mHaveDeferredNodeRemovals = true ;
372
- }
373
-
374
- DecreaseUsage ();
368
+ node->Remove ();
369
+ Platform::Delete (node);
375
370
}
371
+ else
372
+ {
373
+ mObjects .mHaveDeferredNodeRemovals = true ;
374
+ }
375
+
376
+ DecreaseUsage ();
376
377
}
377
378
}
378
379
You can’t perform that action at this time.
0 commit comments