[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: branch: master updated (1.1.2.20070818-26-g96495b7)



The branch, master has been updated
       via  96495b7a87701b2ea8d7eb6b4da206d6c169a85c (commit)
      from  5b2cb25e06604a8d31dff974f323477a78f02f46 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 gschem/src/o_copy.c           |   11 ++++++++---
 libgeda/include/prototype.h   |    1 +
 libgeda/src/o_arc_basic.c     |   13 +------------
 libgeda/src/o_attrib.c        |   24 ++++++++++++++++++++++++
 libgeda/src/o_box_basic.c     |   13 +------------
 libgeda/src/o_bus_basic.c     |   14 +-------------
 libgeda/src/o_circle_basic.c  |   15 ++-------------
 libgeda/src/o_complex_basic.c |   28 ++--------------------------
 libgeda/src/o_line_basic.c    |   14 ++------------
 libgeda/src/o_list.c          |   24 +++++++++++++++++-------
 libgeda/src/o_net_basic.c     |   14 +-------------
 libgeda/src/o_picture.c       |   14 ++------------
 libgeda/src/o_pin_basic.c     |   13 +------------
 13 files changed, 63 insertions(+), 135 deletions(-)


=================
 Commit Messages
=================

commit 96495b7a87701b2ea8d7eb6b4da206d6c169a85c
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Wed Sep 5 13:46:57 2007 +0100

    Fix memory corruption and possible segfault copying attributes
    
    If an object (but not all its attributes) was selected and copied, dangling
    pointers were left in the un-copied attributes. A subsequent copy operation
    containing those missed attributes would attempt to reattach them to the
    copy of their parent. If this had been deleted in the mean time, memory
    corruption and a possible segfault would occur.
    
    Consolidates the duplicated code which sets the ATTRIB property "copied_to"
    into a helper function, o_attrib_list_copied_to(). This is also used to
    clean up after copy operations.

:100644 100644 235531b... 2bad386... M	gschem/src/o_copy.c
:100644 100644 67a74b4... 4e2382f... M	libgeda/include/prototype.h
:100644 100644 b21acce... feba9be... M	libgeda/src/o_arc_basic.c
:100644 100644 080f1af... 5e73dd2... M	libgeda/src/o_attrib.c
:100644 100644 4a40615... 6ca35f0... M	libgeda/src/o_box_basic.c
:100644 100644 752a03b... d85d045... M	libgeda/src/o_bus_basic.c
:100644 100644 e2fe1d1... 9249361... M	libgeda/src/o_circle_basic.c
:100644 100644 acdea3e... 2d88854... M	libgeda/src/o_complex_basic.c
:100644 100644 71b6c1b... 8fe3cb5... M	libgeda/src/o_line_basic.c
:100644 100644 bb146bd... 766a525... M	libgeda/src/o_list.c
:100644 100644 0b98bb8... e44b93b... M	libgeda/src/o_net_basic.c
:100644 100644 40a5d8b... d7c1745... M	libgeda/src/o_picture.c
:100644 100644 a5e9a43... 0029c10... M	libgeda/src/o_pin_basic.c

=========
 Changes
=========

commit 96495b7a87701b2ea8d7eb6b4da206d6c169a85c
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Date:   Wed Sep 5 13:46:57 2007 +0100

    Fix memory corruption and possible segfault copying attributes
    
    If an object (but not all its attributes) was selected and copied, dangling
    pointers were left in the un-copied attributes. A subsequent copy operation
    containing those missed attributes would attempt to reattach them to the
    copy of their parent. If this had been deleted in the mean time, memory
    corruption and a possible segfault would occur.
    
    Consolidates the duplicated code which sets the ATTRIB property "copied_to"
    into a helper function, o_attrib_list_copied_to(). This is also used to
    clean up after copy operations.

diff --git a/gschem/src/o_copy.c b/gschem/src/o_copy.c
index 235531b..2bad386 100644
--- a/gschem/src/o_copy.c
+++ b/gschem/src/o_copy.c
@@ -405,9 +405,6 @@ void o_copy_end(TOPLEVEL *w_current)
                                  w_current,
                                  object->attached_to->copied_to);
 #endif
-
-            /* satisfied copy request */
-            object->attached_to->copied_to = NULL;
           }
         }
 
@@ -449,6 +446,14 @@ void o_copy_end(TOPLEVEL *w_current)
     s_current = s_current->next;
   }
 
+  /* Clean up dangling ATTRIB.copied_to pointers */
+  s_current = geda_list_get_glist( w_current->page_current->selection_list );
+  while(s_current != NULL) {
+    object = s_current->data;
+    o_attrib_list_copied_to (object->attribs, NULL);
+    s_current = g_list_next (s_current);
+  }
+
   /* This is commented out since it breaks the copy of objects.  */
   /* Required connection information is thrown away for some reason */
   /* Of course, commenting this out, will probably break the rotation */
diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index 67a74b4..4e2382f 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -203,6 +203,7 @@ int o_attrib_count_toplevel(TOPLEVEL *toplevel, char *name);
 char *o_attrib_search_toplevel_all(GedaPageList *page_list, char *name);
 OBJECT **o_attrib_return_attribs(OBJECT *object_list, OBJECT *sel_object);
 void o_attrib_free_returned(OBJECT **found_objects);
+void o_attrib_list_copied_to(ATTRIB *list, OBJECT *to_obj);
 
 /* o_basic.c */
 int inside_region(int xmin, int ymin, int xmax, int ymax, int x, int y);
diff --git a/libgeda/src/o_arc_basic.c b/libgeda/src/o_arc_basic.c
index b21acce..feba9be 100644
--- a/libgeda/src/o_arc_basic.c
+++ b/libgeda/src/o_arc_basic.c
@@ -150,7 +150,6 @@ OBJECT *o_arc_copy(TOPLEVEL *toplevel, OBJECT *list_tail,
 		   OBJECT *o_current)
 {
   OBJECT *new_obj;
-  ATTRIB *a_current;
   int color;
 
   if (o_current->saved_color == -1) {
@@ -170,18 +169,8 @@ OBJECT *o_arc_copy(TOPLEVEL *toplevel, OBJECT *list_tail,
                      o_current->line_length, o_current->line_space);
   o_set_fill_options(toplevel, new_obj,
                      FILLING_HOLLOW, -1, -1, -1, -1, -1);
-	
-  a_current = o_current->attribs;
-  if (a_current) {
-    while (a_current) {
 
-      /* head attrib node has prev = NULL */
-      if (a_current->prev != NULL) {
-        a_current->copied_to = new_obj;
-      }
-      a_current = a_current->next;
-    }
-  }
+  o_attrib_list_copied_to (o_current->attribs, new_obj);
 
   return(new_obj);
 }
diff --git a/libgeda/src/o_attrib.c b/libgeda/src/o_attrib.c
index 080f1af..5e73dd2 100644
--- a/libgeda/src/o_attrib.c
+++ b/libgeda/src/o_attrib.c
@@ -2528,3 +2528,27 @@ void o_attrib_free_returned(OBJECT **found_objects)
 
   g_free(found_objects);
 }
+
+
+/*! \brief Set the copied_to property on a list of attributes
+ *  \par Function Description
+ *  Sets the copied_to property on a list of attributes.
+ *  Used when copying objects with attributes.
+ *
+ *  \param [in] list    List of attributes to set
+ *  \param [in] to_obj  OBEJCT to set copied_to
+ */
+void o_attrib_list_copied_to(ATTRIB *list, OBJECT *to_obj)
+{
+  ATTRIB *a_current;
+
+  a_current = list;
+  while ( a_current ) {
+
+    /* head attrib node has prev = NULL */
+    if (a_current->prev != NULL) {
+      a_current->copied_to = to_obj;
+    }
+    a_current = a_current->next;
+  }
+}
diff --git a/libgeda/src/o_box_basic.c b/libgeda/src/o_box_basic.c
index 4a40615..6ca35f0 100644
--- a/libgeda/src/o_box_basic.c
+++ b/libgeda/src/o_box_basic.c
@@ -142,7 +142,6 @@ OBJECT *o_box_add(TOPLEVEL *toplevel, OBJECT *object_list,
 OBJECT *o_box_copy(TOPLEVEL *toplevel, OBJECT *list_tail, OBJECT *o_current)
 {
   OBJECT *new_obj;
-  ATTRIB *a_current;
   int color;
 	
   if (o_current->saved_color == -1) {
@@ -188,17 +187,7 @@ OBJECT *o_box_copy(TOPLEVEL *toplevel, OBJECT *list_tail, OBJECT *o_current)
   o_box_recalc(toplevel, new_obj);
 
   /* new_obj->attribute = 0;*/
-  a_current = o_current->attribs;
-  if (a_current) {
-    while ( a_current ) {
-      
-      /* head attrib node has prev = NULL */
-      if (a_current->prev != NULL) {
-	a_current->copied_to = new_obj;
-      }
-      a_current = a_current->next;
-    }
-  }
+  o_attrib_list_copied_to (o_current->attribs, new_obj);
 
   /* return the new tail of the object list */
   return(new_obj);
diff --git a/libgeda/src/o_bus_basic.c b/libgeda/src/o_bus_basic.c
index 752a03b..d85d045 100644
--- a/libgeda/src/o_bus_basic.c
+++ b/libgeda/src/o_bus_basic.c
@@ -245,7 +245,6 @@ void o_bus_translate_world(TOPLEVEL *toplevel, int x1, int y1, OBJECT *object)
 OBJECT *o_bus_copy(TOPLEVEL *toplevel, OBJECT *list_tail, OBJECT *o_current)
 {
   OBJECT *new_obj;
-  ATTRIB *a_current;
   int color;
 
   if (o_current->saved_color == -1) {
@@ -268,18 +267,7 @@ OBJECT *o_bus_copy(TOPLEVEL *toplevel, OBJECT *list_tail, OBJECT *o_current)
   new_obj->line->x[1] = o_current->line->x[1];
   new_obj->line->y[1] = o_current->line->y[1];
 
-  a_current = o_current->attribs;
-
-  if (a_current) {
-    while ( a_current ) {
-
-      /* head attrib node has prev = NULL */
-      if (a_current->prev != NULL) {
-        a_current->copied_to = new_obj;
-      }
-      a_current = a_current->next;
-    }
-  }
+  o_attrib_list_copied_to (o_current->attribs, new_obj);
 
   return(new_obj);
 }
diff --git a/libgeda/src/o_circle_basic.c b/libgeda/src/o_circle_basic.c
index e2fe1d1..9249361 100644
--- a/libgeda/src/o_circle_basic.c
+++ b/libgeda/src/o_circle_basic.c
@@ -129,7 +129,6 @@ OBJECT *o_circle_copy(TOPLEVEL *toplevel, OBJECT *list_tail,
 		      OBJECT *o_current)
 {
   OBJECT *new_obj;
-  ATTRIB *a_current;
   int color;
 
   if (o_current->saved_color == -1) {
@@ -172,18 +171,8 @@ OBJECT *o_circle_copy(TOPLEVEL *toplevel, OBJECT *list_tail,
   o_circle_recalc(toplevel, new_obj);
 
   /*	new_obj->attribute = 0;*/
-  a_current = o_current->attribs;
-  if (a_current) {
-    while ( a_current ) {
-      
-      /* head attrib node has prev = NULL */
-      if (a_current->prev != NULL) {
-	a_current->copied_to = new_obj;
-      }
-      a_current = a_current->next;
-    }
-  }
-  
+  o_attrib_list_copied_to (o_current->attribs, new_obj);
+
   return(new_obj);
 }
 
diff --git a/libgeda/src/o_complex_basic.c b/libgeda/src/o_complex_basic.c
index acdea3e..2d88854 100644
--- a/libgeda/src/o_complex_basic.c
+++ b/libgeda/src/o_complex_basic.c
@@ -931,7 +931,6 @@ OBJECT *o_complex_copy(TOPLEVEL *toplevel, OBJECT *list_tail,
 		       OBJECT *o_current)
 {
   OBJECT *new_obj=NULL;
-  ATTRIB *a_current;
   int color;
   int selectable;
   const CLibSymbol *clib = NULL;
@@ -966,18 +965,7 @@ OBJECT *o_complex_copy(TOPLEVEL *toplevel, OBJECT *list_tail,
   /* here you need to create a list of attributes which need to be 
    * connected to the new list, probably make an attribute list and
    * fill it with sid's of the attributes */
-  a_current = o_current->attribs;
-  if (a_current) {
-    while ( a_current ) {
-
-      /* head attrib node has prev = NULL */	
-      if (a_current->prev != NULL) {
-        a_current->copied_to = new_obj;	
-      }
-	
-      a_current = a_current->next;
-    }
-  }
+  o_attrib_list_copied_to (o_current->attribs, new_obj);
 
   return(new_obj);
 }
@@ -991,7 +979,6 @@ OBJECT *o_complex_copy_embedded(TOPLEVEL *toplevel, OBJECT *list_tail,
 {
   OBJECT *new_obj=NULL;
   OBJECT *temp_list;
-  ATTRIB *a_current;
   int color;
   int selectable;
 
@@ -1027,18 +1014,7 @@ OBJECT *o_complex_copy_embedded(TOPLEVEL *toplevel, OBJECT *list_tail,
   /* here you need to create a list of attributes which need to be 
    * connected to the new list, probably make an attribute list and
    * fill it with sid's of the attributes */
-  a_current = o_current->attribs;
-  if (a_current) {
-    while ( a_current ) {
-
-      /* head attrib node has prev = NULL */	
-      if (a_current->prev != NULL) {
-        a_current->copied_to = new_obj;	
-      }
-	
-      a_current = a_current->next;
-    }
-  }
+  o_attrib_list_copied_to (o_current->attribs, new_obj);
 
   return(new_obj);
 }
diff --git a/libgeda/src/o_line_basic.c b/libgeda/src/o_line_basic.c
index 71b6c1b..8fe3cb5 100644
--- a/libgeda/src/o_line_basic.c
+++ b/libgeda/src/o_line_basic.c
@@ -124,7 +124,6 @@ OBJECT *o_line_add(TOPLEVEL *toplevel, OBJECT *object_list,
 OBJECT *o_line_copy(TOPLEVEL *toplevel, OBJECT *list_tail, OBJECT *o_current)
 {
   OBJECT *new_obj;
-  ATTRIB *a_current;
   int color;
 
   if (o_current->saved_color == -1) {
@@ -170,17 +169,8 @@ OBJECT *o_line_copy(TOPLEVEL *toplevel, OBJECT *list_tail, OBJECT *o_current)
   o_line_recalc(toplevel, o_current);
   
   /* new_obj->attribute = 0;*/
-  a_current = o_current->attribs;
-  if (a_current) {
-    while ( a_current ) {
-      /* head attrib node has prev = NULL */
-      if (a_current->prev != NULL) {
-	a_current->copied_to = new_obj;
-      }
-      a_current = a_current->next;
-    }
-  }
-  
+  o_attrib_list_copied_to (o_current->attribs, new_obj);
+
   /* return the new tail of the object list */
   return(new_obj);
 }
diff --git a/libgeda/src/o_list.c b/libgeda/src/o_list.c
index bb146bd..766a525 100644
--- a/libgeda/src/o_list.c
+++ b/libgeda/src/o_list.c
@@ -219,16 +219,20 @@ OBJECT *o_list_copy_all(TOPLEVEL *toplevel, OBJECT *src_list_head,
           o_attrib_attach(toplevel,
                           toplevel->page_current->object_parent,
                           dest, src->attached_to->copied_to);     
-
-                                /* satisfied copy request */
-          src->attached_to->copied_to = NULL;
-        } 
+        }
       }
     }
 
     src = src->next;
   }
 
+  /* Clean up dangling ATTRIB.copied_to pointers */
+  src = src_list_head;
+  while(src != NULL) {
+    o_attrib_list_copied_to (src->attribs, NULL);
+    src = src->next;
+  }
+
   toplevel->ADDING_SEL = adding_sel_save;
   toplevel->page_current->object_parent = temp_parent;
 
@@ -336,9 +340,7 @@ OBJECT *o_list_copy_all_selection2(TOPLEVEL *toplevel,
           o_attrib_attach(toplevel,
                           toplevel->page_current->object_parent,
                           dest, object->attached_to->copied_to);     
-                                /* satisfied copy request */
-          object->attached_to->copied_to = NULL;
-        } 
+        }
       }
     }
 
@@ -348,6 +350,14 @@ OBJECT *o_list_copy_all_selection2(TOPLEVEL *toplevel,
     src = src->next;
   }
 
+  /* Clean up dangling ATTRIB.copied_to pointers */
+  src = src_list_head;
+  while(src != NULL) {
+    object = src->data;
+    o_attrib_list_copied_to (object->attribs, NULL);
+    src = g_list_next (src);
+  }
+
   toplevel->ADDING_SEL = adding_sel_save;
   toplevel->page_current->object_parent = temp_parent;
 
diff --git a/libgeda/src/o_net_basic.c b/libgeda/src/o_net_basic.c
index 0b98bb8..e44b93b 100644
--- a/libgeda/src/o_net_basic.c
+++ b/libgeda/src/o_net_basic.c
@@ -258,7 +258,6 @@ OBJECT *o_net_copy(TOPLEVEL *toplevel, OBJECT *list_tail,
 		   OBJECT *o_current)
 {
   OBJECT *new_obj;
-  ATTRIB *a_current;
   int color;
 
   if (o_current->saved_color == -1) {
@@ -280,18 +279,7 @@ OBJECT *o_net_copy(TOPLEVEL *toplevel, OBJECT *list_tail,
   new_obj->line->x[1] = o_current->line->x[1];
   new_obj->line->y[1] = o_current->line->y[1];
 
-  a_current = o_current->attribs;
-
-  if (a_current) {
-    while (a_current) {
-
-      /* head attrib node has prev = NULL */
-      if (a_current->prev != NULL) {
-        a_current->copied_to = new_obj;
-      }
-      a_current = a_current->next;
-    }
-  }
+  o_attrib_list_copied_to (o_current->attribs, new_obj);
 
   return (new_obj);
 }
diff --git a/libgeda/src/o_picture.c b/libgeda/src/o_picture.c
index 40a5d8b..d7c1745 100644
--- a/libgeda/src/o_picture.c
+++ b/libgeda/src/o_picture.c
@@ -722,7 +722,6 @@ OBJECT *o_picture_copy(TOPLEVEL *toplevel, OBJECT *list_tail,
 		       OBJECT *o_current)
 {
   OBJECT *new_obj;
-  ATTRIB *a_current;
   int color;
 	
   if (o_current->saved_color == -1) {
@@ -779,17 +778,8 @@ OBJECT *o_picture_copy(TOPLEVEL *toplevel, OBJECT *list_tail,
   o_picture_recalc(toplevel, new_obj);
   
   /* new_obj->attribute = 0;*/
-  a_current = o_current->attribs;
-  if (a_current) {
-    while ( a_current ) {
-      /* head attrib node has prev = NULL */
-      if (a_current->prev != NULL) {
-	a_current->copied_to = new_obj;
-      }
-      a_current = a_current->next;
-    }
-  }
-  
+  o_attrib_list_copied_to (o_current->attribs, new_obj);
+
   /* return the new tail of the object list */
   return(new_obj);
 } 
diff --git a/libgeda/src/o_pin_basic.c b/libgeda/src/o_pin_basic.c
index a5e9a43..0029c10 100644
--- a/libgeda/src/o_pin_basic.c
+++ b/libgeda/src/o_pin_basic.c
@@ -269,7 +269,6 @@ void o_pin_translate_world(TOPLEVEL *toplevel, int x1, int y1, OBJECT *object)
 OBJECT *o_pin_copy(TOPLEVEL *toplevel, OBJECT *list_tail, OBJECT *o_current)
 {
   OBJECT *new_obj;
-  ATTRIB *a_current;
   int color;
 
   if (o_current->saved_color == -1) {
@@ -289,17 +288,7 @@ OBJECT *o_pin_copy(TOPLEVEL *toplevel, OBJECT *list_tail, OBJECT *o_current)
   new_obj->line->y[1] = o_current->line->y[1];
 
   /*	new_obj->attribute = 0;*/
-  a_current = o_current->attribs;
-  if (a_current) {
-    while ( a_current ) {
-
-      /* head attrib node has prev = NULL */
-      if (a_current->prev != NULL) {
-        a_current->copied_to = new_obj;
-      }
-      a_current = a_current->next;
-    }
-  }
+  o_attrib_list_copied_to (o_current->attribs, new_obj);
 
   return(new_obj);
 }




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs