Skip to content

Possible nullptr exception in connection::get_origin? #561

Open
@hollowowl

Description

@hollowowl

Hi,
It seems std::string const & connection<config>::get_origin() may try to call a member function of nullptr (websocketpp\impl\connection_impl.hpp, line 67):
return m_processor->get_origin(m_request);

Several times I've got an "Access Violation" message due to the fact that m_processor is nullptr.

Why not to check m_processor before calling get_origin(m_request)?
I mean something like:

if (m_processor) return m_processor->get_origin(m_request);
else return string();

or

if (m_processor) return m_processor->get_origin(m_request);
else throw some_specific_exception();

Or maybe I'm just using it wrong?
My usage:

    if (!hdl.expired())
    {
        try
        {
            return server.get_con_from_hdl(hdl)->get_origin();
        }
        catch (std::exception& ex)
        {
            //Process exception
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions