[Libpst-commits] r49 - trunk
Joseph Nahmias
jello at alioth.debian.org
Thu Dec 7 04:55:13 CET 2006
Author: jello
Date: 2006-12-07 04:55:13 +0100 (Thu, 07 Dec 2006)
New Revision: 49
Modified:
trunk/libpst.c
Log:
make sure list, item, and id2_head are freed in _pst_parse_item()
Modified: trunk/libpst.c
===================================================================
--- trunk/libpst.c 2006-12-07 02:57:45 UTC (rev 48)
+++ trunk/libpst.c 2006-12-07 03:55:13 UTC (rev 49)
@@ -1090,6 +1090,7 @@
// }
if (d_ptr->desc == NULL) {
+ if (id2_head) _pst_free_id2(id2_head);
DEBUG_WARN(("why is d_ptr->desc == NULL? I don't want to do anything else with this record\n"));
DEBUG_RET();
return NULL;
@@ -1097,6 +1098,7 @@
if ((list = _pst_parse_block(pf, d_ptr->desc->id, id2_head)) == NULL) {
+ if (id2_head) _pst_free_id2(id2_head);
DEBUG_WARN(("_pst_parse_block() returned an error for d_ptr->desc->id [%#x]\n", d_ptr->desc->id));
DEBUG_RET();
return NULL;
@@ -1106,6 +1108,9 @@
memset(item, 0, sizeof(pst_item));
if (_pst_process(list, item)) {
+ if (item) free(item);
+ if (list) _pst_free_list(list);
+ if (id2_head) _pst_free_id2(id2_head);
DEBUG_WARN(("_pst_process() returned non-zero value. That is an error\n"));
_pst_free_list(list);
DEBUG_RET();
@@ -1125,6 +1130,8 @@
DEBUG_EMAIL(("ATTACHEMENT processing attachement\n"));
if ((list = _pst_parse_block(pf, id_ptr->id, id2_head)) == NULL) {
+ if (item) free(item);
+ if (id2_head) _pst_free_id2(id2_head);
DEBUG_WARN(("ERROR error processing main attachment record\n"));
DEBUG_RET();
return NULL;
@@ -1140,12 +1147,13 @@
item->current_attach = item->attach;
if (_pst_process(list, item)) {
+ if (id2_head) _pst_free_id2(id2_head);
+ if (list) _pst_free_list(list);
DEBUG_WARN(("ERROR _pst_process() failed with attachments\n"));
- _pst_free_list(list);
DEBUG_RET();
return NULL;
}
- _pst_free_list(list);
+ if (list) _pst_free_list(list);
// now we will have initial information of each attachment stored in item->attach...
// we must now read the secondary record for each based on the id2 val associated with
@@ -1164,11 +1172,11 @@
item->current_attach = attach;
if (_pst_process(list, item)) {
DEBUG_WARN(("ERROR _pst_process() failed with an attachment\n"));
- _pst_free_list(list);
+ if (list) _pst_free_list(list); list = NULL;
attach = attach->next;
continue;
}
- _pst_free_list(list);
+ if (list) _pst_free_list(list); list = NULL;
if ((id_ptr = _pst_getID2(id2_head, attach->id2_val)) != NULL) {
// id2_val has been updated to the ID2 value of the datablock containing the
// attachment data
@@ -1185,7 +1193,7 @@
item->current_attach = item->attach; //reset back to first
}
- _pst_free_id2(id2_head);
+ _pst_free_id2(id2_head); id2_head = NULL;
DEBUG_RET();
@@ -3390,6 +3398,7 @@
pst_index_ll *i_ptr = NULL;
pst_index2_ll *i2_ptr = NULL;
DEBUG_ENT("_pst_build_id2");
+
if (head_ptr != NULL) {
head = head_ptr;
while (head_ptr != NULL)
@@ -3397,6 +3406,7 @@
}
if (_pst_read_block_size(pf, list->offset, list->size, &buf, PST_NO_ENC,0) < list->size) {
//an error occured in block read
+ if (buf) free(buf);
WARN(("block read error occured. offset = %#x, size = %#x\n", list->offset, list->size));
DEBUG_RET();
return NULL;
@@ -3407,6 +3417,7 @@
LE16_CPU(block_head.count);
if (block_head.type != 0x0002) { // some sort of constant?
+ if (buf) free(buf);
WARN(("Unknown constant [%#x] at start of id2 values [offset %#x].\n", block_head.type, list->offset));
DEBUG_RET();
return NULL;
@@ -3845,8 +3856,10 @@
unsigned char fdepth;
pst_index_ll *ptr = NULL;
size_t rsize, z;
+
DEBUG_ENT("_pst_read_block_size");
DEBUG_READ(("Reading block from %#x, %i bytes\n", offset, size));
+
fpos = ftell(pf->fp);
fseek(pf->fp, offset, SEEK_SET);
if (*buf != NULL) {
More information about the Libpst-commits
mailing list