aboutsummaryrefslogtreecommitdiff
path: root/gdb/rust-exp.y
diff options
context:
space:
mode:
authorDan Robertson <danlrobertson89@gmail.com>2018-04-28 03:18:00 +0000
committerTom Tromey <tom@tromey.com>2018-04-30 23:02:01 -0600
commit1632f8baf04e7351f387e58957fc04498d90987d (patch)
treecf269dd68ec1db621ddadd18abe7851d1f249318 /gdb/rust-exp.y
parente31efe56455e4a0e84d2157e942e51f8ac94e9fc (diff)
downloadgdb-1632f8baf04e7351f387e58957fc04498d90987d.zip
gdb-1632f8baf04e7351f387e58957fc04498d90987d.tar.gz
gdb-1632f8baf04e7351f387e58957fc04498d90987d.tar.bz2
rust: Fix null deref when casting (PR 23124)
Fix a null dereference when casting a value to a unit type. ChangeLog 2018-04-28 Dan Robertson <danlrobertson89@gmail.com> PR rust/23124 * gdb/rust-exp.y (convert_params_to_types): Ensure that the params pointer is not null before dereferencing it. testsuite/ChangeLog 2018-04-28 Dan Robertson <danlrobertson89@gmail.com> PR rust/23124 * gdb.rust/expr.exp: Test that the unit type is correctly parsed when casting.
Diffstat (limited to 'gdb/rust-exp.y')
-rw-r--r--gdb/rust-exp.y7
1 files changed, 5 insertions, 2 deletions
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
index 56aa689..9f21498 100644
--- a/gdb/rust-exp.y
+++ b/gdb/rust-exp.y
@@ -2019,8 +2019,11 @@ convert_params_to_types (struct parser_state *state, rust_op_vector *params)
{
std::vector<struct type *> result;
- for (const rust_op *op : *params)
- result.push_back (convert_ast_to_type (state, op));
+ if (params != nullptr)
+ {
+ for (const rust_op *op : *params)
+ result.push_back (convert_ast_to_type (state, op));
+ }
return result;
}