[c++,08/12] scm-symbol.c: Add (domain_enum) casts
Commit Message
We currently pass integers as domain_enums to lookup_symbol. The
most obvious fix is to add casts there.
I first thought of changing the type of the domain variables to
domain_enum. However, because we pass a pointer to them to
gdbscm_parse_function_args, which expects them to be integers (because
of the format string), I don't think it would be correct. If the enum
does not have the same size as an int, gdbscm_parse_function_args could
write past the memory of domain, overwriting something else on the
stack.
gdb/ChangeLog:
* guile/scm-symbol.c (gdbscm_lookup_global_symbol): Add
domain_enum cast.
(gdbscm_lookup_symbol): Likewise.
---
gdb/guile/scm-symbol.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
Simon Marchi <simon.marchi@polymtl.ca> writes:
> We currently pass integers as domain_enums to lookup_symbol. The
> most obvious fix is to add casts there.
>
> I first thought of changing the type of the domain variables to
> domain_enum. However, because we pass a pointer to them to
> gdbscm_parse_function_args, which expects them to be integers (because
> of the format string), I don't think it would be correct. If the enum
> does not have the same size as an int, gdbscm_parse_function_args could
> write past the memory of domain, overwriting something else on the
> stack.
>
> gdb/ChangeLog:
>
> * guile/scm-symbol.c (gdbscm_lookup_global_symbol): Add
> domain_enum cast.
> (gdbscm_lookup_symbol): Likewise.
> ---
> gdb/guile/scm-symbol.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
> index 81e4d50..10400be 100644
> --- a/gdb/guile/scm-symbol.c
> +++ b/gdb/guile/scm-symbol.c
> @@ -622,7 +622,8 @@ gdbscm_lookup_symbol (SCM name_scm, SCM rest)
>
> TRY
> {
> - symbol = lookup_symbol (name, block, domain, &is_a_field_of_this).symbol;
> + symbol = lookup_symbol (name, block, (domain_enum) domain,
> + &is_a_field_of_this).symbol;
> }
> CATCH (ex, RETURN_MASK_ALL)
> {
> @@ -662,7 +663,7 @@ gdbscm_lookup_global_symbol (SCM name_scm, SCM rest)
>
> TRY
> {
> - symbol = lookup_global_symbol (name, NULL, domain).symbol;
> + symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol;
> }
> CATCH (ex, RETURN_MASK_ALL)
> {
LGTM
@@ -622,7 +622,8 @@ gdbscm_lookup_symbol (SCM name_scm, SCM rest)
TRY
{
- symbol = lookup_symbol (name, block, domain, &is_a_field_of_this).symbol;
+ symbol = lookup_symbol (name, block, (domain_enum) domain,
+ &is_a_field_of_this).symbol;
}
CATCH (ex, RETURN_MASK_ALL)
{
@@ -662,7 +663,7 @@ gdbscm_lookup_global_symbol (SCM name_scm, SCM rest)
TRY
{
- symbol = lookup_global_symbol (name, NULL, domain).symbol;
+ symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol;
}
CATCH (ex, RETURN_MASK_ALL)
{