Skip to content

Commit

Permalink
Added validation of mapgen weight
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrikLundell committed Aug 17, 2024
1 parent a83322d commit af89099
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,14 @@ load_mapgen_function( const JsonObject &jio, const std::string &id_base, const p
const point &total )
{
dbl_or_var weight = get_dbl_or_var( jio, "weight", false, 1000 );
if( weight.min.is_constant() && ( weight.min.constant() < 0 ||
weight.min.constant() >= 2147483648 ) ) {
jio.throw_error_at( "weight", "min value out of bounds (0 - max int)" );
}
if( weight.pair && weight.max.is_constant() && ( weight.max.constant() < 0 ||
weight.max.constant() >= 2147483648 ) ) {
jio.throw_error_at( "weight", "max value out of bounds (0 - max int)" );
}

if( jio.get_bool( "disabled", false ) ) {
jio.allow_omitted_members();
Expand Down

0 comments on commit af89099

Please sign in to comment.