Merge pull request #170 from dhy2000/vortex-schedule

Fix use-after-free in mempool
This commit is contained in:
tinebp 2024-08-13 18:47:05 -07:00 committed by GitHub
commit aafb6072c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -176,23 +176,23 @@ public:
{}
void* operator new(size_t /*size*/) {
return allocator().allocate();
return allocator_.allocate();
}
void operator delete(void* ptr) {
allocator().deallocate(ptr);
allocator_.deallocate(ptr);
}
protected:
Func func_;
Pkt pkt_;
static MemoryPool<SimCallEvent<Pkt>>& allocator() {
static MemoryPool<SimCallEvent<Pkt>> instance(64);
return instance;
}
static MemoryPool<SimCallEvent<Pkt>> allocator_;
};
template <typename Pkt>
MemoryPool<SimCallEvent<Pkt>> SimCallEvent<Pkt>::allocator_(64);
///////////////////////////////////////////////////////////////////////////////
template <typename Pkt>
@ -209,23 +209,23 @@ public:
{}
void* operator new(size_t /*size*/) {
return allocator().allocate();
return allocator_.allocate();
}
void operator delete(void* ptr) {
allocator().deallocate(ptr);
allocator_.deallocate(ptr);
}
protected:
const SimPort<Pkt>* port_;
Pkt pkt_;
static MemoryPool<SimPortEvent<Pkt>>& allocator() {
static MemoryPool<SimPortEvent<Pkt>> instance(64);
return instance;
}
static MemoryPool<SimPortEvent<Pkt>> allocator_;
};
template <typename Pkt>
MemoryPool<SimPortEvent<Pkt>> SimPortEvent<Pkt>::allocator_(64);
///////////////////////////////////////////////////////////////////////////////
class SimContext;