[libpst-commits] r86 - trunk

Chris Halls halls at alioth.debian.org
Mon Jan 29 20:21:14 CET 2007


Author: halls
Date: 2007-01-29 20:21:13 +0100 (Mon, 29 Jan 2007)
New Revision: 86

Modified:
   trunk/ChangeLog
   trunk/libpst.c
Log:
* Fix crash with unknown reference type
* Fix more memory issues detected by valgrind


Index: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	(revision 85)
+++ trunk/ChangeLog	(revision 86)
@@ -6,7 +6,9 @@
 	* Map IPM.Task items to PST_TYPE_TASK.
 	* Applied patch to remove compiler warnings, thanks!
 	  (SourceForge #304314)
-	* lspst fixes: 
+	* Fix crash with unknown reference type
+	* Fix more memory issues detected by valgrind
+	* lspst: 
 	  * Add usage mesage and option parsing using getopt
 	    (SourceForge #304199)
       * Fix crash caused by invalid free calls
Index: trunk/libpst.c
===================================================================
--- trunk/libpst.c	(revision 85)
+++ trunk/libpst.c	(revision 86)
@@ -1379,6 +1379,7 @@
     }
     // allocate an array of count num_recs to contain sizeof(struct_pst_num_item)
     na_ptr->items = (struct _pst_num_item**) xmalloc(sizeof(struct _pst_num_item)*num_list);
+    memset(na_ptr->items, 0, sizeof(struct _pst_num_item)*num_list);
     na_ptr->count_item = num_list;
     na_ptr->count_array = num_recs; // each record will have a record of the total number of records
     x = 0;
@@ -1540,8 +1541,9 @@
 	      DEBUG_WARN(("not able to read the ID2 data. Setting to be read later. %#x\n",
 		    type_d_rec->id));
 	      na_ptr->items[x]->size = 0;
+	      na_ptr->items[x]->type = type_d_rec->id;
+              free(na_ptr->items[x]->data);
 	      na_ptr->items[x]->data = NULL;
-	      na_ptr->items[x]->type = type_d_rec->id;
 	    } 
 	    DEBUG_EMAIL(("Read %i bytes into a buffer at %p\n",
 			 na_ptr->items[x]->size, na_ptr->items[x]->data));
@@ -1563,6 +1565,7 @@
 	  na_ptr->items[x]->type = table_rec.ref_type;
       } else {
 	WARN(("ERROR Unknown ref_type %#x\n", table_rec.ref_type));
+	if (buf) free (buf);
 	if (na_head)
 		_pst_free_list(na_head);
 	DEBUG_RET();
@@ -2130,8 +2133,9 @@
 	DEBUG_EMAIL(("Attachment Size - "));
 	NULL_CHECK(attach);
 	MOVE_NEXT(attach);
-	memcpy(&(attach->size), list->items[x]->data, 
-	       sizeof(attach->size));
+	t = (*(int32_t*)list->items[x]->data);
+	LE32_CPU(t);
+	attach->size = t;
 	DEBUG_EMAIL(("%i\n", attach->size));
 	//INC_CHECK_X();
 	break;
@@ -3382,10 +3386,10 @@
   DEBUG_ENT("_pst_free_list");
   while (list != NULL) {
     while (x < list->count_item) {
-      if (list->items[x]->data != NULL) {
-	free (list->items[x]->data);
-      }
       if (list->items[x] != NULL) {
+        if (list->items[x]->data != NULL) {
+          free (list->items[x]->data);
+        }
 	free (list->items[x]);
       }
       x++;



More information about the libpst-commits mailing list