From 127a850beb866d43ac2d6ae0aa503c1f5453e7a4 Mon Sep 17 00:00:00 2001 From: Remington Brasga Date: Fri, 29 Mar 2019 15:05:29 -0700 Subject: [PATCH] Fix arena allocation size in NewEmptyInternalIterator (#4905) Summary: NewEmptyInternalIterator with arena mistakenly used EmptyIterator to allocate the size from area but then initialized it to a totally different object: EmptyInternalIterator. The patch fixes that. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4905 Differential Revision: D14689840 Pulled By: maysamyabandeh fbshipit-source-id: af64fd8ee93d5a4ad54691c792e5ecc5efabc887 --- table/iterator.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/table/iterator.cc b/table/iterator.cc index fd3adc427..e42ca260b 100644 --- a/table/iterator.cc +++ b/table/iterator.cc @@ -157,10 +157,6 @@ class EmptyInternalIterator : public InternalIteratorBase { }; } // namespace -Iterator* NewEmptyIterator() { - return new EmptyIterator(Status::OK()); -} - Iterator* NewErrorIterator(const Status& status) { return new EmptyIterator(status); } @@ -180,7 +176,7 @@ InternalIteratorBase* NewErrorInternalIterator(const Status& status, if (arena == nullptr) { return NewErrorInternalIterator(status); } else { - auto mem = arena->AllocateAligned(sizeof(EmptyIterator)); + auto mem = arena->AllocateAligned(sizeof(EmptyInternalIterator)); return new (mem) EmptyInternalIterator(status); } } @@ -201,7 +197,7 @@ InternalIteratorBase* NewEmptyInternalIterator(Arena* arena) { if (arena == nullptr) { return NewEmptyInternalIterator(); } else { - auto mem = arena->AllocateAligned(sizeof(EmptyIterator)); + auto mem = arena->AllocateAligned(sizeof(EmptyInternalIterator)); return new (mem) EmptyInternalIterator(Status::OK()); } }