Commit 39493e82 authored by sdefresne's avatar sdefresne Committed by Commit bot

Fix crash when deleting ReadingListStore via ReadingListModelStorage*.

ReadingListStore inherits from multiple classes, including from
ReadingListModelStorage that does not define a virtual destructor.

Since ReadingListModelImpl has a scoped_ptr to ReadingListModelStorage,
it calls the base destructor with a pointer that does not correspond
to memory returned by "new" (it points to somewhere inside the memory
block).

The issue can be fixed by defining a virtual destructor on the base
class ReadingListModelStorage (as all class with virtual method should
do). Also mark the class a non-copyable since copying would cause slicing.

BUG=673169

Review-Url: https://codereview.chromium.org/2563303002
Cr-Commit-Position: refs/heads/master@{#437800}
parent 0d282c20
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <vector> #include <vector>
#include "base/macros.h"
#include "components/reading_list/ios/reading_list_entry.h" #include "components/reading_list/ios/reading_list_entry.h"
class ReadingListModel; class ReadingListModel;
...@@ -22,6 +23,9 @@ class ReadingListModelStorage { ...@@ -22,6 +23,9 @@ class ReadingListModelStorage {
public: public:
class ScopedBatchUpdate; class ScopedBatchUpdate;
ReadingListModelStorage() {}
virtual ~ReadingListModelStorage() {}
// Sets the model the Storage is backing. // Sets the model the Storage is backing.
// This will trigger store initalization and load persistent entries. // This will trigger store initalization and load persistent entries.
virtual void SetReadingListModel(ReadingListModel* model, virtual void SetReadingListModel(ReadingListModel* model,
...@@ -48,8 +52,15 @@ class ReadingListModelStorage { ...@@ -48,8 +52,15 @@ class ReadingListModelStorage {
class ScopedBatchUpdate { class ScopedBatchUpdate {
public: public:
ScopedBatchUpdate() {}
virtual ~ScopedBatchUpdate() {} virtual ~ScopedBatchUpdate() {}
private:
DISALLOW_COPY_AND_ASSIGN(ScopedBatchUpdate);
}; };
private:
DISALLOW_COPY_AND_ASSIGN(ReadingListModelStorage);
}; };
#endif // COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_STORAGE_H_ #endif // COMPONENTS_READING_LIST_IOS_READING_LIST_MODEL_STORAGE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment