Bug 1333038 - Use 'modern' pointers to fix crash due to nsMsgLineStreamBuffer object being deleted while still in use.

Suspected "use after free" in nsMsgLineStreamBuffer::ReadNextLine() leading to crash since object may be destroyed while still in use on another thread.

Tag #1273
This commit is contained in:
Matt A. Tobin 2019-11-10 21:59:52 -05:00 committed by Roy Tam
commit 14590876b2
13 changed files with 14 additions and 26 deletions

View file

@ -70,6 +70,8 @@ class nsIInputStream;
class NS_MSG_BASE nsMsgLineStreamBuffer
{
public:
NS_INLINE_DECL_REFCOUNTING(nsMsgLineStreamBuffer)
// aBufferSize -- size of the buffer you want us to use for buffering stream data
// aEndOfLinetoken -- The delimiter string to be used for determining the end of line. This
// allows us to parse platform specific end of line endings by making it
@ -83,7 +85,6 @@ public:
// lines are terminated with a CR only, you need to set aLineToken to CR ('\r')
nsMsgLineStreamBuffer(uint32_t aBufferSize, bool aAllocateNewLines,
bool aEatCRLFs = true, char aLineToken = '\n'); // specify the size of the buffer you want the class to use....
virtual ~nsMsgLineStreamBuffer();
// Caller must free the line returned using PR_Free
// aEndOfLinetoken -- delimiter used to denote the end of a line.
@ -93,6 +94,8 @@ public:
nsresult GrowBuffer(int32_t desiredSize);
void ClearBuffer();
bool NextLineAvailable();
private:
virtual ~nsMsgLineStreamBuffer();
protected:
bool m_eatCRLFs;
bool m_allocateNewLines;