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: dangling pointer in so_list


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


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