Skip to content

Commit

Permalink
Fix: memory leak in PacketReader / Writer
Browse files Browse the repository at this point in the history
The leak occurred because of missing virtual destructors
  • Loading branch information
evpo committed Feb 7, 2018
1 parent 902fdba commit c9b055f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions deps/libencryptmsg/src/packet_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ namespace LibEncryptMsg
public:
PacketRWBase(SessionState &state, bool is_final_packet)
:state_(state), is_final_packet_(is_final_packet){}

virtual ~PacketRWBase(){}
PacketRWBase(const PacketRWBase&) = delete;
PacketRWBase &operator=(const PacketRWBase&) = delete;

// Reads packet body and writes its payload while setting metadata_out fields
// Payload is the contained packets or empty if there are no packets inside
EmsgResult Read(OutStream &out)
Expand Down
5 changes: 5 additions & 0 deletions deps/libencryptmsg/src/packet_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ namespace LibEncryptMsg
void Write(OutStream &out);
void Finish(OutStream &out);
InBufferStream &GetInStream();

virtual ~PacketWriter(){}
PacketWriter(const PacketWriter&) = delete;
PacketWriter &operator=(const PacketWriter&) = delete;

protected:
InBufferStream in_;
InBufferStream out_;
Expand Down

0 comments on commit c9b055f

Please sign in to comment.