From 328dd45deea2a77522b24d36a1be2fb48086d8c2 Mon Sep 17 00:00:00 2001 From: BevapDin Date: Tue, 24 Dec 2019 11:42:07 +0100 Subject: [PATCH] Explicitly check the value of a boolean JSON object member. --- src/npctalk.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/npctalk.cpp b/src/npctalk.cpp index a1dc0575de24c..b0fa2e0c49064 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -2918,6 +2918,10 @@ dynamic_line_t::dynamic_line_t( const JsonObject &jo ) const dynamic_line_t no = from_member( jo, "no" ); for( const std::string &sub_member : dialogue_data::simple_string_conds ) { if( jo.has_bool( sub_member ) ) { + // This also marks the member as visited. + if( !jo.get_bool( sub_member ) ) { + jo.throw_error( "value must be true", sub_member ); + } dcondition = conditional_t( sub_member ); function = [dcondition, yes, no]( const dialogue & d ) { return ( dcondition( d ) ? yes : no )( d );