Open Bug 1280493 Opened 4 years ago Updated 3 years ago

(coverity) resource leak: mailnews/local/src/nsPop3Protocol.cpp: |line| is not released in an early error return

Categories

(MailNews Core :: Networking: POP, defect)

defect
Not set

Tracking

(Not tracked)

People

(Reporter: ishikawa, Unassigned)

References

(Blocks 1 open bug, )

Details

(Keywords: coverity, memory-leak, Whiteboard: CID 1137485)

Coverity found this:


3278    m_pop3ConData->pause_for_read = true;
3279
3280    bool pauseForMoreData = false;
    2. alloc_fn: Storage is returned from allocation function ReadNextLine. [show details]
    3. var_assign: Assigning: line = storage returned from this->m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv, true).
3281    char *line = m_lineStreamBuffer->ReadNextLine(inputStream, status, pauseForMoreData, &rv, true);
    4. Condition mozilla::detail::log_test(POP3LOGMODULE, mozilla::LogLevel::Info), taking false branch
3282    MOZ_LOG(POP3LOGMODULE, LogLevel::Info, (POP3LOG("RECV: %s"), line));
    5. Condition !!NS_FAILED_impl(rv), taking true branch
    6. Condition !!NS_FAILED_impl(rv), taking true branch
    7. Condition (bool)!!NS_FAILED_impl(rv), taking true branch
3283    if (NS_FAILED(rv))
    CID 1137485 (#2-1 of 2): Resource leak (RESOURCE_LEAK)8. leaked_storage: Variable line going out of scope leaks the storage it points to.
3284      return -1;
3285

observation:
|line| is freed by the following code at the end of the  function.

3426 PR_Free(line); 
3427 return(0);

We should free |line| similarly before the early return on 3284.
Keywords: mlk
You need to log in before you can comment on or make changes to this bug.