Skip to content

Commit

Permalink
Bugfix for issue-1793: using the heap to properly store the default v…
Browse files Browse the repository at this point in the history
…alues
  • Loading branch information
Matthias Koefferlein committed Jul 20, 2024
1 parent 4383802 commit 9a79838
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/gsi/gsi/gsiExpression.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1036,10 +1036,10 @@ VariantUserClassImpl::execute_gsi (const tl::ExpressionParserContext & /*context
// leave it to the consumer to establish the default values (that is faster)
break;
}
const tl::Variant &def_value = a->spec ()->default_value ();
// NOTE: this const_cast means we need to take care that we do not use default values on "out" parameters.
// Otherwise there is a chance we will modify the default value.
gsi::push_arg (arglist, *a, const_cast<tl::Variant &> (def_value), &heap);
// Note: we will use the default value variant for longer, so push it to the heap (#1793)
tl::Variant *def_value = new tl::Variant (a->spec ()->default_value ());
heap.push (def_value);
gsi::push_arg (arglist, *a, *def_value, &heap);
} else {
throw tl::Exception (tl::to_string ("No argument provided (positional or keyword) and no default value available"));
}
Expand Down
8 changes: 4 additions & 4 deletions src/pya/pya/pyaCallables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,10 @@ push_args (gsi::SerialArgs &arglist, const gsi::MethodBase *meth, PyObject *args
// leave it to the consumer to establish the default values (that is faster)
break;
}
const tl::Variant &def_value = a->spec ()->default_value ();
// NOTE: this const_cast means we need to take care that we do not use default values on "out" parameters.
// Otherwise there is a chance we will modify the default value.
gsi::push_arg (arglist, *a, const_cast<tl::Variant &> (def_value), &heap);
// Note: we will use the default value variant for longer, so push it to the heap (#1793)
tl::Variant *def_value = new tl::Variant (a->spec ()->default_value ());
heap.push (def_value);
gsi::push_arg (arglist, *a, *def_value, &heap);
} else {
throw tl::Exception (tl::to_string (tr ("No argument provided (positional or keyword) and no default value available")));
}
Expand Down
8 changes: 4 additions & 4 deletions src/rba/rba/rba.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1125,10 +1125,10 @@ push_args (gsi::SerialArgs &arglist, const gsi::MethodBase *meth, VALUE *argv, i
// leave it to the consumer to establish the default values (that is faster)
break;
}
const tl::Variant &def_value = a->spec ()->default_value ();
// NOTE: this const_cast means we need to take care that we do not use default values on "out" parameters.
// Otherwise there is a chance we will modify the default value.
gsi::push_arg (arglist, *a, const_cast<tl::Variant &> (def_value), &heap);
// Note: we will use the default value variant for longer, so push it to the heap (#1793)
tl::Variant *def_value = new tl::Variant (a->spec ()->default_value ());
heap.push (def_value);
gsi::push_arg (arglist, *a, *def_value, &heap);
} else {
throw tl::Exception (tl::to_string (tr ("No argument provided (positional or keyword) and no default value available")));
}
Expand Down

0 comments on commit 9a79838

Please sign in to comment.