Commit 03785a1f authored by Petr Rockai's avatar Petr Rockai
Browse files

bricks: Fix invalid memory access in what() of error and system_error.

parent e8ff9c06
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -35,11 +35,11 @@ namespace brq
    {
        int _exit;

        error( int exit, const char *err )
        error( int exit, const auto &err )
            : std::runtime_error( err ), _exit( exit )
        {}

        error( const char *err )
        error( const auto &err )
            : std::runtime_error( err ), _exit( 1 )
        {}

@@ -66,7 +66,7 @@ namespace brq
        {
            if ( _moved_from || std::uncaught_exceptions() )
                return; /* terminate if unwinding? */
            auto args = std::tuple_cat( _args, std::make_tuple( _what.buffer() ) );
            auto args = std::tuple_cat( _args, std::make_tuple( _what.str() ) );
            std::apply( []( auto... a ) -> void { throw exc( a... ); }, args );
        }

@@ -87,8 +87,8 @@ namespace brq

    struct system_error : std::system_error, stacked_error
    {
        system_error( const char *w ) : system_error( errno, w ) {}
        system_error( int e, const char *w ) : std::system_error( e, std::system_category(), w ) {}
        system_error( const auto &w ) : system_error( errno, w ) {}
        system_error( int e, const auto &w ) : std::system_error( e, std::system_category(), w ) {}
        const char *describe() const noexcept { return what(); }
    };