comparison src/libpst.c @ 36:6fe121a971c9 stable-0-5-7

valgrind fixes
author carl
date Thu, 09 Aug 2007 15:46:34 -0700
parents b2f247463b83
children 2ad7ef0a3c4f
comparison
equal deleted inserted replaced
35:b2f247463b83 36:6fe121a971c9
721 DEBUG_RET(); 721 DEBUG_RET();
722 return -1; 722 return -1;
723 } 723 }
724 bptr = buf; 724 bptr = buf;
725 item_count = (int)(unsigned)(buf[ITEM_COUNT_OFFSET]); 725 item_count = (int)(unsigned)(buf[ITEM_COUNT_OFFSET]);
726 memcpy(&desc_rec, buf+BACKLINK_OFFSET, sizeof(desc_rec)); 726 memcpy(&desc_rec.d_id, buf+BACKLINK_OFFSET, sizeof(u_int32_t)); // for valgrind, only have 3 ints here, not 4
727 LE32_CPU(desc_rec.d_id); 727 LE32_CPU(desc_rec.d_id);
728 if (desc_rec.d_id != linku1) { 728 if (desc_rec.d_id != linku1) {
729 DEBUG_WARN(("Backlink %#x in this node does not match required %#x\n", desc_rec.d_id, linku1)); 729 DEBUG_WARN(("Backlink %#x in this node does not match required %#x\n", desc_rec.d_id, linku1));
730 if (buf) free(buf); 730 if (buf) free(buf);
731 DEBUG_RET(); 731 DEBUG_RET();
1081 u_int32_t num_recs; 1081 u_int32_t num_recs;
1082 u_int32_t count_rec; 1082 u_int32_t count_rec;
1083 u_int32_t num_list; 1083 u_int32_t num_list;
1084 u_int32_t cur_list; 1084 u_int32_t cur_list;
1085 u_int32_t block_type; 1085 u_int32_t block_type;
1086 u_int32_t rec_size; 1086 u_int32_t rec_size = 0;
1087 u_int32_t ind_ptr; 1087 u_int32_t ind_ptr;
1088 unsigned char* list_start; 1088 unsigned char* list_start;
1089 unsigned char* t_ptr; 1089 unsigned char* t_ptr;
1090 unsigned char* fr_ptr; 1090 unsigned char* fr_ptr;
1091 unsigned char* to_ptr; 1091 unsigned char* to_ptr;
1092 unsigned char* ind2_end; 1092 unsigned char* ind2_end;
1093 unsigned char* ind2_ptr; 1093 unsigned char* ind2_ptr = NULL;
1094 size_t read_size=0; 1094 size_t read_size=0;
1095 pst_x_attrib_ll *mapptr; 1095 pst_x_attrib_ll *mapptr;
1096 1096
1097 struct { 1097 struct {
1098 u_int16_t type; 1098 u_int16_t type;
1186 } 1186 }
1187 list_start = block_offset2.from; 1187 list_start = block_offset2.from;
1188 to_ptr = block_offset2.to; 1188 to_ptr = block_offset2.to;
1189 num_list = (to_ptr - list_start)/sizeof(table_rec); 1189 num_list = (to_ptr - list_start)/sizeof(table_rec);
1190 num_recs = 1; // only going to be one object in these blocks 1190 num_recs = 1; // only going to be one object in these blocks
1191 rec_size = 0; // doesn't matter cause there is only one object
1192 } 1191 }
1193 else if (block_hdr.type == 0x7CEC) { //type 2 1192 else if (block_hdr.type == 0x7CEC) { //type 2
1194 block_type = 2; 1193 block_type = 2;
1195 1194
1196 if (_pst_getBlockOffsetPointer(pf, i2_head, buf, read_size, ind_ptr, block_hdr.offset, &block_offset3)) { 1195 if (_pst_getBlockOffsetPointer(pf, i2_head, buf, read_size, ind_ptr, block_hdr.offset, &block_offset3)) {
1290 na_head = na_ptr; 1289 na_head = na_ptr;
1291 // allocate an array of count num_recs to contain sizeof(struct_pst_num_item) 1290 // allocate an array of count num_recs to contain sizeof(struct_pst_num_item)
1292 na_ptr->items = (struct _pst_num_item**) xmalloc(sizeof(struct _pst_num_item)*num_list); 1291 na_ptr->items = (struct _pst_num_item**) xmalloc(sizeof(struct _pst_num_item)*num_list);
1293 na_ptr->count_item = num_list; 1292 na_ptr->count_item = num_list;
1294 na_ptr->count_array = num_recs; // each record will have a record of the total number of records 1293 na_ptr->count_array = num_recs; // each record will have a record of the total number of records
1294 for (x=0; x<num_list; x++) na_ptr->items[x] = NULL;
1295 x = 0; 1295 x = 0;
1296 1296
1297 DEBUG_EMAIL(("going to read %i (%#x) items\n", na_ptr->count_item, na_ptr->count_item)); 1297 DEBUG_EMAIL(("going to read %i (%#x) items\n", na_ptr->count_item, na_ptr->count_item));
1298 1298
1299 fr_ptr = list_start; // initialize fr_ptr to the start of the list. 1299 fr_ptr = list_start; // initialize fr_ptr to the start of the list.
3096 return 0; 3096 return 0;
3097 } 3097 }
3098 3098
3099 3099
3100 int32_t _pst_free_list(pst_num_array *list) { 3100 int32_t _pst_free_list(pst_num_array *list) {
3101 int32_t x = 0;
3102 pst_num_array *l; 3101 pst_num_array *l;
3103 DEBUG_ENT("_pst_free_list"); 3102 DEBUG_ENT("_pst_free_list");
3104 while (list) { 3103 while (list) {
3105 while (x < list->count_item) { 3104 int32_t x = 0;
3106 if (list->items[x]->data) { 3105 if (list->items) {
3107 free (list->items[x]->data); 3106 while (x < list->count_item) {
3107 if (list->items[x]) {
3108 if (list->items[x]->data) {
3109 free (list->items[x]->data);
3110 }
3111 free (list->items[x]);
3112 }
3113 x++;
3108 } 3114 }
3109 if (list->items[x]) {
3110 free (list->items[x]);
3111 }
3112 x++;
3113 }
3114 if (list->items) {
3115 free(list->items); 3115 free(list->items);
3116 } 3116 }
3117 l = list; 3117 l = list;
3118 list = list->next; 3118 list = list->next;
3119 free (l); 3119 free (l);
3120 x = 0;
3121 } 3120 }
3122 DEBUG_RET(); 3121 DEBUG_RET();
3123 return 1; 3122 return 1;
3124 } 3123 }
3125 3124
3829 size_t _pst_ff_getIDblock_dec(pst_file *pf, u_int32_t id, unsigned char **b) { 3828 size_t _pst_ff_getIDblock_dec(pst_file *pf, u_int32_t id, unsigned char **b) {
3830 size_t r; 3829 size_t r;
3831 DEBUG_ENT("_pst_ff_getIDblock_dec"); 3830 DEBUG_ENT("_pst_ff_getIDblock_dec");
3832 DEBUG_INDEX(("for id %#x\n", id)); 3831 DEBUG_INDEX(("for id %#x\n", id));
3833 r = _pst_ff_getIDblock(pf, id, b); 3832 r = _pst_ff_getIDblock(pf, id, b);
3834 DEBUG_HEXDUMPC(*b, r, 16);
3835 int noenc = (id & 2); // disable encryption 3833 int noenc = (id & 2); // disable encryption
3836 if ((pf->encryption) & !(noenc)) { 3834 if ((pf->encryption) & !(noenc)) {
3837 _pst_decrypt(*b, r, pf->encryption); 3835 _pst_decrypt(*b, r, pf->encryption);
3838 DEBUG_HEXDUMPC(*b, r, 16); 3836 }
3839 } 3837 DEBUG_HEXDUMPC(*b, r, 16);
3840 DEBUG_RET(); 3838 DEBUG_RET();
3841 return r; 3839 return r;
3842 } 3840 }
3843 3841
3844 3842