r4564 - trunk/src/target/opkg/libopkg

tick at docs.openmoko.org tick at docs.openmoko.org
Wed Jul 30 16:01:54 CEST 2008


Author: tick
Date: 2008-07-30 16:01:54 +0200 (Wed, 30 Jul 2008)
New Revision: 4564

Modified:
   trunk/src/target/opkg/libopkg/pkg.c
   trunk/src/target/opkg/libopkg/pkg_hash.c
   trunk/src/target/opkg/libopkg/void_list.c
Log:
opkg: fix the crashing issue. 
      It's a hanging pointer.  
      Using installed_files without get and free



Modified: trunk/src/target/opkg/libopkg/pkg.c
===================================================================
--- trunk/src/target/opkg/libopkg/pkg.c	2008-07-30 12:31:19 UTC (rev 4563)
+++ trunk/src/target/opkg/libopkg/pkg.c	2008-07-30 14:01:54 UTC (rev 4564)
@@ -1737,8 +1737,7 @@
 	       // opkg_message(conf, OPKG_DEBUG2, "pkg %s: file=%s\n", pkg->name, installed_file);
 	       file_hash_set_file_owner(conf, installed_file, pkg);
 	  }
-	  //FIXME: mark this line. Thid avoid crash, But the reference count shall be balanced. (If there are some delay after file_hash_set_file_owner, it wont crash (Pondering why?))
-	  //pkg_free_installed_files(pkg);
+	  pkg_free_installed_files(pkg);
      }
      pkg_vec_free(installed_pkgs);
 

Modified: trunk/src/target/opkg/libopkg/pkg_hash.c
===================================================================
--- trunk/src/target/opkg/libopkg/pkg_hash.c	2008-07-30 12:31:19 UTC (rev 4563)
+++ trunk/src/target/opkg/libopkg/pkg_hash.c	2008-07-30 14:01:54 UTC (rev 4564)
@@ -648,10 +648,13 @@
      // opkg_message(conf, OPKG_DEBUG2, "owning_pkg=%s filename=%s\n", owning_pkg->name, file_name);
      hash_table_insert(file_hash, file_name, owning_pkg); 
      if (old_owning_pkg) {
+	  pkg_get_installed_files(old_owning_pkg);
 	  str_list_remove_elt(old_owning_pkg->installed_files, file_name);
+	  pkg_free_installed_files(old_owning_pkg);
 	  /* mark this package to have its filelist written */
 	  old_owning_pkg->state_flag |= SF_FILELIST_CHANGED;
 	  owning_pkg->state_flag |= SF_FILELIST_CHANGED;
+	  
      }
      return 0;
 }

Modified: trunk/src/target/opkg/libopkg/void_list.c
===================================================================
--- trunk/src/target/opkg/libopkg/void_list.c	2008-07-30 12:31:19 UTC (rev 4563)
+++ trunk/src/target/opkg/libopkg/void_list.c	2008-07-30 14:01:54 UTC (rev 4564)
@@ -160,6 +160,15 @@
      void_list_elt_t *old_elt = NULL;
      void *old_data = NULL;
 
+     if (!list) {
+          fprintf(stderr, "Error: void_list_remove_elt list is NULL\n");
+          return NULL;
+     }
+     if (!target_data) {
+          fprintf(stderr, "Error: void_list_remove_elt target_data is NULL\n");
+	  return NULL;
+     }
+
      /* first element */
      if (list->head && list->head->data && (cmp(list->head->data, target_data) == 0)) {
 	  old_elt = list->head;





More information about the commitlog mailing list