Skip to content

Commit

Permalink
Fix destruct http message double free (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
waahm7 authored Dec 2, 2022
1 parent 3e55662 commit 904b0c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
2 changes: 2 additions & 0 deletions include/aws/crt/RefCounted.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0.
*/

#include <aws/common/assert.h>
#include <memory>
#include <mutex>

Expand Down Expand Up @@ -47,6 +48,7 @@ namespace Aws
std::shared_ptr<T> tmpStrongPtr;

m_mutex.lock();
AWS_ASSERT(m_count > 0 && "refcount has gone negative");
if (m_count-- == 1)
{
std::swap(m_strongPtr, tmpStrongPtr);
Expand Down
16 changes: 1 addition & 15 deletions source/http/HttpRequestResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,7 @@ namespace Aws
}
}

HttpMessage::~HttpMessage()
{
if (m_message != nullptr)
{
aws_input_stream *old_stream = aws_http_message_get_body_stream(m_message);
if (old_stream != nullptr)
{
aws_input_stream_destroy(old_stream);
}

aws_http_message_release(m_message);

m_message = nullptr;
}
}
HttpMessage::~HttpMessage() { m_message = aws_http_message_release(m_message); }

std::shared_ptr<Aws::Crt::Io::InputStream> HttpMessage::GetBody() const noexcept { return m_bodyStream; }

Expand Down

0 comments on commit 904b0c9

Please sign in to comment.