From: Jim Blandy <jimb@codesourcery.com>
To: msnyder@sonic.net
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] target_read_string, potential memory leak.
Date: Wed, 08 Aug 2007 21:48:00 -0000 [thread overview]
Message-ID: <m3tzr9u29c.fsf@codesourcery.com> (raw)
In-Reply-To: <15524.12.7.175.2.1186597958.squirrel@webmail.sonic.net> (msnyder@sonic.net's message of "Wed, 8 Aug 2007 11:32:38 -0700 (PDT)")
msnyder@sonic.net writes:
>> msnyder@sonic.net writes:
>>> OK -- it would be pretty stupid to call target_read_string without
>>> passing it a buffer, but if we're going to check it for null...
>>
>> I don't think the contract for target_read_string permits STRING to be
>> null. I think either the test should go, or we should add a
>> gdb_assert (string).
>
> Agreed. Thus?
Agreed, thus. :)
> Index: target.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/target.c,v
> retrieving revision 1.145
> diff -p -r1.145 target.c
> *** target.c 24 Jul 2007 12:49:24 -0000 1.145
> --- target.c 8 Aug 2007 18:31:57 -0000
> *************** target_read_string (CORE_ADDR memaddr, c
> *** 919,924 ****
> --- 919,926 ----
> char *bufptr;
> unsigned int nbytes_read = 0;
>
> + gdb_assert (string);
> +
> /* Small for testing. */
> buffer_allocated = 4;
> buffer = xmalloc (buffer_allocated);
> *************** target_read_string (CORE_ADDR memaddr, c
> *** 968,977 ****
> nbytes_read += tlen;
> }
> done:
> if (errnop != NULL)
> *errnop = errcode;
> - if (string != NULL)
> - *string = buffer;
> return nbytes_read;
> }
>
> --- 970,978 ----
> nbytes_read += tlen;
> }
> done:
> + *string = buffer;
> if (errnop != NULL)
> *errnop = errcode;
> return nbytes_read;
> }
>
next prev parent reply other threads:[~2007-08-08 21:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-05 3:29 msnyder
2007-08-06 22:30 ` Jim Blandy
2007-08-08 18:32 ` msnyder
2007-08-08 21:48 ` Jim Blandy [this message]
2007-08-08 22:03 ` msnyder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3tzr9u29c.fsf@codesourcery.com \
--to=jimb@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=msnyder@sonic.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox