From f1efb1a2f8aed8a2e7500d792bd0da1b465241e5 Mon Sep 17 00:00:00 2001 From: Qrox Date: Thu, 26 Dec 2019 22:07:19 +0800 Subject: [PATCH] Fix use-after-free in translations.cpp --- src/translations.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/translations.cpp b/src/translations.cpp index c00601b533829..0f58e0bfeea30 100644 --- a/src/translations.cpp +++ b/src/translations.cpp @@ -475,7 +475,8 @@ void translation::deserialize( JsonIn &jsin ) #ifndef CATA_IN_TOOL if( test_mode ) { check_style = !jsobj.has_member( "//NOLINT(cata-text-style)" ); - throw_error = [&jsobj]( const std::string & msg, const int offset ) { + // Copying jsobj to avoid use-after-free + throw_error = [jsobj]( const std::string & msg, const int offset ) { jsobj.get_raw( "str" )->error( msg, offset ); }; }