Re: [PATCH] Remove an instance of MAX_REGISTER_SIZE from record-full.c

Pedro Alves
2017-06-22T13:45:34Z

On 06/22/2017 02:44 PM, Alan Hayward wrote:
>
>> On 21 Jun 2017, at 11:52, Pedro Alves <palves@redhat.com> wrote:
>>
>> On 06/12/2017 02:59 PM, Alan Hayward wrote:
>>
>>> diff --git a/gdb/record-full.c b/gdb/record-full.c
>>> index 31ff558d2a633cff71d3e6082e42f5d6fb88bcf1..4f73e2a5ad0d4a2407b31a1d391e813147e15798 100644
>>> --- a/gdb/record-full.c
>>> +++ b/gdb/record-full.c
>>> @@ -698,7 +698,7 @@ record_full_exec_insn (struct regcache *regcache,
>>> {
>>> case record_full_reg: /* reg */
>>> {
>>> - gdb_byte reg[MAX_REGISTER_SIZE];
>>> + gdb_byte *reg = (gdb_byte *) xmalloc (entry->u.reg.len);
>>>
>>> if (record_debug > 1)
>>> fprintf_unfiltered (gdb_stdlog,
>>> @@ -711,6 +711,7 @@ record_full_exec_insn (struct regcache *regcache,
>>> regcache_cooked_write (regcache, entry->u.reg.num,
>>> record_full_get_loc (entry));
>>> memcpy (record_full_get_loc (entry), reg, entry->u.reg.len);
>>> + xfree (reg);
>>
>> You can use
>> gdb::byte_vector reg (entry->u.reg.len);
>> to avoid the explicit xfree here.
>>
>> (and a potential leak if regcache_* throws).
>>
>> Thanks,
>> Pedro Alves
>>
>
> Updated and retested.
>
> Ok to commit?

Sure.

Thanks,
Pedro Alves