solib.c: minor cleanup

Jim Blandy jimb@zwingli.cygnus.com
Thu Mar 16 16:01:00 GMT 2000


2000-03-16  Jim Blandy  <jimb@redhat.com>

	* solib.c (current_sos): Be more careful about freeing the new
	so_list node if an error occurs.

Index: solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -c -r1.3 -r1.4
*** solib.c	2000/03/15 16:55:07	1.3
--- solib.c	2000/03/16 23:12:42	1.4
***************
*** 1091,1096 ****
--- 1091,1097 ----
      {
        struct so_list *new
  	= (struct so_list *) xmalloc (sizeof (struct so_list));
+       struct cleanup *old_chain = make_cleanup (free, new);
        memset (new, 0, sizeof (*new));
  
        new->lmaddr = lm;
***************
*** 1104,1112 ****
           does have a name, so we can no longer use a missing name to
           decide when to ignore it. */
        if (IGNORE_FIRST_LINK_MAP_ENTRY (new))
! 	{
! 	  free_so (new);
! 	}
        else
  	{
  	  int errcode;
--- 1105,1111 ----
           does have a name, so we can no longer use a missing name to
           decide when to ignore it. */
        if (IGNORE_FIRST_LINK_MAP_ENTRY (new))
! 	free_so (new);
        else
  	{
  	  int errcode;
***************
*** 1140,1145 ****
--- 1139,1146 ----
  	      link_ptr = &new->next;
  	    }
  	}
+ 
+       discard_cleanups (old_chain);
      }
  
    return head;


More information about the Gdb-patches mailing list