Skip to content

Commit

Permalink
Fix memory leak in http writer's binary data cache (issue #11)
Browse files Browse the repository at this point in the history
  • Loading branch information
trueqbit committed Sep 2, 2020
1 parent e7f39c2 commit a70dc07
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion include/pion/http/writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,19 @@ class PION_API writer :


/// used to cache binary data included within the payload content
class binary_cache_t : public std::vector<std::pair<const char *, size_t> > {
class binary_cache_t : protected std::vector<std::pair<const char *, size_t> > {
public:
~binary_cache_t() {
for (iterator i=begin(); i!=end(); ++i) {
delete[] i->first;
}
}
void clear() {
for (iterator i = begin(); i != end(); ++i) {
delete[] i->first;
}
std::vector<std::pair<const char*, size_t> >::clear();
}
inline boost::asio::const_buffer add(const void *ptr, const size_t size) {
char *data_ptr = new char[size];
memcpy(data_ptr, ptr, size);
Expand Down

0 comments on commit a70dc07

Please sign in to comment.