This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: dangling pointer in so_list
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Aleksandar Ristovski <aristovski at qnx dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Fri, 2 Sep 2011 22:17:15 +0200
- Subject: Re: dangling pointer in so_list
- References: <j3m3u5$2m0$1@dough.gmane.org> <j3m4hd$647$1@dough.gmane.org> <j3qkcq$mou$1@dough.gmane.org>
On Fri, 02 Sep 2011 15:06:34 +0200, Aleksandar Ristovski wrote:
> --- gdb/solib.c 30 Aug 2011 02:48:05 -0000 1.153
> +++ gdb/solib.c 1 Sep 2011 19:56:37 -0000
> @@ -633,6 +633,23 @@ solib_read_symbols (struct so_list *so,
> return 0;
> }
>
> +/* Return 1 if KNOWN->objfile is used by any other so_list object in the
> + HEAD list. Return 0 otherwise. */
> +
> +static int
> +used (const struct so_list *const known, const struct so_list *const head)
> +{
> + const struct so_list *pivot;
> + int found = 0;
> +
> + for (pivot = head; pivot != NULL && !found; pivot = pivot->next)
> + {
> + if (pivot != known && pivot->objfile == known->objfile)
> + found = 1;
> + }
> + return found;
> +}
static int
solist_used (const struct so_list *const known)
{
const struct so_list *so;
for (so = so_list_head; so != NULL; so = so->next)
if (so != known && so->objfile == known->objfile)
return 1;
return 0;
}
(untested for consts)
I find both the `head' (we are on solib.c) and `found' variables needless
there.
Use some solib-identifying name (such as the common solib_ prefix).
OK without the `head' parameter and with the solib_ prefix.
GNU/Linux compatible testcase is probably not possible, one would need two
loaded solibs with the same vaddr of their `.text' section.
Thanks,
Jan