* [PATCH] Use rs->buf after getpkt
@ 2014-01-25 12:18 Yao Qi
2014-02-04 19:25 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Yao Qi @ 2014-01-25 12:18 UTC (permalink / raw)
To: gdb-patches
Hi,
The following code snippet looks wrong to me
char *buf = rs->buf;
getpkt (&rs->buf, &rs->buf_size, 0);
packet_ok (buf, );
if rs->buf is reallocated in getpkt, buf points to an out of dated
memory. This patch removes local 'buf' and uses rs->buf.
Regression tested on x86_64-linux. Is it OK?
gdb:
2014-01-25 Yao Qi <yao@codesourcery.com>
* remote.c (remote_pass_signals): Remove local 'buf' and use
rs->buf.
(remote_program_signals): Likewise.
---
gdb/remote.c | 8 ++------
1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/gdb/remote.c b/gdb/remote.c
index 7297df0..ece05d1 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -1732,11 +1732,9 @@ remote_pass_signals (int numsigs, unsigned char *pass_signals)
*p = 0;
if (!rs->last_pass_packet || strcmp (rs->last_pass_packet, pass_packet))
{
- char *buf = rs->buf;
-
putpkt (pass_packet);
getpkt (&rs->buf, &rs->buf_size, 0);
- packet_ok (buf, &remote_protocol_packets[PACKET_QPassSignals]);
+ packet_ok (rs->buf, &remote_protocol_packets[PACKET_QPassSignals]);
if (rs->last_pass_packet)
xfree (rs->last_pass_packet);
rs->last_pass_packet = pass_packet;
@@ -1785,11 +1783,9 @@ remote_program_signals (int numsigs, unsigned char *signals)
if (!rs->last_program_signals_packet
|| strcmp (rs->last_program_signals_packet, packet) != 0)
{
- char *buf = rs->buf;
-
putpkt (packet);
getpkt (&rs->buf, &rs->buf_size, 0);
- packet_ok (buf, &remote_protocol_packets[PACKET_QProgramSignals]);
+ packet_ok (rs->buf, &remote_protocol_packets[PACKET_QProgramSignals]);
xfree (rs->last_program_signals_packet);
rs->last_program_signals_packet = packet;
}
--
1.7.7.6
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Use rs->buf after getpkt
2014-01-25 12:18 [PATCH] Use rs->buf after getpkt Yao Qi
@ 2014-02-04 19:25 ` Pedro Alves
2014-02-05 12:29 ` Yao Qi
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2014-02-04 19:25 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On 01/25/2014 12:16 PM, Yao Qi wrote:
> Hi,
> The following code snippet looks wrong to me
>
> char *buf = rs->buf;
>
> getpkt (&rs->buf, &rs->buf_size, 0);
> packet_ok (buf, );
>
> if rs->buf is reallocated in getpkt, buf points to an out of dated
> memory.
Indeed.
> This patch removes local 'buf' and uses rs->buf.
>
> Regression tested on x86_64-linux. Is it OK?
OK.
--
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Use rs->buf after getpkt
2014-02-04 19:25 ` Pedro Alves
@ 2014-02-05 12:29 ` Yao Qi
0 siblings, 0 replies; 3+ messages in thread
From: Yao Qi @ 2014-02-05 12:29 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On 02/05/2014 03:25 AM, Pedro Alves wrote:
> On 01/25/2014 12:16 PM, Yao Qi wrote:
>> Hi,
>> The following code snippet looks wrong to me
>>
>> char *buf = rs->buf;
>>
>> getpkt (&rs->buf, &rs->buf_size, 0);
>> packet_ok (buf, );
>>
>> if rs->buf is reallocated in getpkt, buf points to an out of dated
>> memory.
>
> Indeed.
>
>> This patch removes local 'buf' and uses rs->buf.
>>
>> Regression tested on x86_64-linux. Is it OK?
>
> OK.
>
Thanks for the review. Patch is pushed.
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-05 12:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-25 12:18 [PATCH] Use rs->buf after getpkt Yao Qi
2014-02-04 19:25 ` Pedro Alves
2014-02-05 12:29 ` Yao Qi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox