fix: do not leak when inserting the same page twice, just update
This commit is contained in:
@@ -95,6 +95,16 @@ page_insert_file (struct file *file, off_t ofs, void *upage,
|
||||
uint32_t read_bytes, uint32_t zero_bytes, bool writable,
|
||||
enum page_type type)
|
||||
{
|
||||
/* If page exists, just update it. */
|
||||
struct page_entry *existing = page_get (upage);
|
||||
if (existing != NULL)
|
||||
{
|
||||
ASSERT (existing->read_bytes == read_bytes);
|
||||
ASSERT (existing->zero_bytes == zero_bytes);
|
||||
existing->writable = existing->writable || writable;
|
||||
return existing;
|
||||
}
|
||||
|
||||
struct page_entry *page = malloc(sizeof (struct page_entry));
|
||||
if (page == NULL)
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user