diff options
author | Tom Tromey <tom@tromey.com> | 2016-06-09 09:46:53 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2016-06-29 10:03:45 -0600 |
commit | 9d78f827e0da9ab6fda2d6ef2d59cebb805b411f (patch) | |
tree | d68e95e4e3f51f476d6cd21f9c69609545a168b1 /gdb/mi | |
parent | b287eca391bbb10e709fb8ba9a56be166ab2ff1d (diff) | |
download | gdb-9d78f827e0da9ab6fda2d6ef2d59cebb805b411f.zip gdb-9d78f827e0da9ab6fda2d6ef2d59cebb805b411f.tar.gz gdb-9d78f827e0da9ab6fda2d6ef2d59cebb805b411f.tar.bz2 |
PR gdb/17210 - fix possible memory leak in read_memory_robust
PR gdb/17210 concerns a possible memory leak in read_memory_robust.
The bug can happen because read_memory_robust allocates memory, does
not install any cleanups, and invokes QUIT. Similarly, target_read
calls QUIT, so it too can potentially throw.
The fix is to install cleanups to guard the allocated memory.
Built and regtested on x86-64 Fedora 23. I couldn't think of a way to
test this, so no new test; and of course this means it should have
more careful review.
2016-06-29 Tom Tromey <tom@tromey.com>
PR gdb/17210:
* target.c (free_memory_read_result_vector): Take a pointer to the
VEC as an argument.
(read_memory_robust): Install a cleanup for "result".
* mi/mi-main.c (mi_cmd_data_read_memory_bytes): Update.
Diffstat (limited to 'gdb/mi')
-rw-r--r-- | gdb/mi/mi-main.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 188547b..b1cbd8b 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1636,7 +1636,7 @@ mi_cmd_data_read_memory_bytes (char *command, char **argv, int argc) result = read_memory_robust (current_target.beneath, addr, length); - cleanups = make_cleanup (free_memory_read_result_vector, result); + cleanups = make_cleanup (free_memory_read_result_vector, &result); if (VEC_length (memory_read_result_s, result) == 0) error (_("Unable to read memory.")); |