[Libpst-devel] More memory leaks

Nigel Horne njh at bandsman.co.uk
Fri Apr 28 12:55:30 UTC 2006


This patch removes the last memory leaks I have with my sample data as
it stands.

-Nigel Horne

*** Olibpst.c	Fri Apr 28 12:22:24 2006
--- libpst.c	Fri Apr 28 13:19:41 2006
***************
*** 700,705 ****
--- 700,706 ----
    if (pf->index2_depth-depth == 0) {
      // leaf node
      if (_pst_read_block_size(pf, offset, DESC_BLOCK_SIZE, &buf, 0, 0) < DESC_BLOCK_SIZE) {
+ 	if (buf) free(buf);
        DEBUG_WARN(("I didn't get all the index that I wanted. _pst_read_block_size returned less than requested\n"));
        DEBUG_RET();
        return -1;
***************
*** 1117,1122 ****
--- 1118,1125 ----
  
      DEBUG_EMAIL(("ATTACHEMENT processing attachement\n"));
      if ((list = _pst_parse_block(pf, id_ptr->id, id2_head)) == NULL) {
+ 	_pst_free_id2(id2_head);
+ 	_pst_free_list(list);
        DEBUG_WARN(("ERROR error processing main attachment record\n"));
        DEBUG_RET();
        return NULL;
***************
*** 1132,1139 ****
      item->current_attach = item->attach;
  
      if (_pst_process(list, item)) {
        DEBUG_WARN(("ERROR _pst_process() failed with attachments\n"));
-       _pst_free_list(list);
        DEBUG_RET();
        return NULL;
      }
--- 1135,1143 ----
      item->current_attach = item->attach;
  
      if (_pst_process(list, item)) {
+ 	_pst_free_id2(id2_head);
+ 	_pst_free_list(list);
        DEBUG_WARN(("ERROR _pst_process() failed with attachments\n"));
        DEBUG_RET();
        return NULL;
      }
***************
*** 4079,4086 ****
    unsigned char fdepth;
  
    DEBUG_ENT("_pst_ff_compile_ID");
!   if ((a = _pst_ff_getIDblock(pf, id, &buf3))==0)
!     return 0;
    if ((buf3[0] != 0x1)) { // if bit 8 is set) {
      //  if ((buf3)[0] != 0x1 && (buf3)[1] > 4) {
      DEBUG_WARN(("WARNING: buffer doesn't start with 0x1, but I expected it to or doesn't have it's two-bit set!\n"));
--- 4083,4093 ----
    unsigned char fdepth;
  
    DEBUG_ENT("_pst_ff_compile_ID");
! 	if ((a = _pst_ff_getIDblock(pf, id, &buf3))==0) {
! 		if(buf3)
! 			free(buf3);
! 		return 0;
! 	}
    if ((buf3[0] != 0x1)) { // if bit 8 is set) {
      //  if ((buf3)[0] != 0x1 && (buf3)[1] > 4) {
      DEBUG_WARN(("WARNING: buffer doesn't start with 0x1, but I expected it to or doesn't have it's two-bit set!\n"));



More information about the Libpst-devel mailing list