This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfc] Prompt memory management/cleanups


On Wednesday 20 July 2011 15:30:19, Phil Muldoon wrote:
> s = get_prompt (0)
> set_prompt (s, 0)
> 
> Without that check, 'PROMPT (level)' would be freed, but 's' points to
> that.  So you set garbage.   get_prompt returns a pointer, not a copy.

I'm probably missing something, but isn't it just
a matter of instead of having:

+       xfree (PROMPT (level));
+       PROMPT (level) =  xstrdup (s);

you have:

+		 char *newp = xstrdup (s);
+       xfree (PROMPT (level));
+       PROMPT (level) = newp;

?

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]