On Sun, 2009-03-22 at 15:04 +0100, Julien Kerihuel wrote:
> On Fri, 2009-03-20 at 19:04 -0700, Chuck Bohling wrote:
> > valgrind is reporting a memory leak.
> >  
> > I'm using the code from libmapi-0.8.2-ROMULUS.tar.gz. Is it fixed in
> > the trunk?
> 
> Hi Chuck,
> 
> Looks like I have missed some memory leaks. I am currently working on it
> and should come with preliminary patches for trunk within the next few
> hours.
> 
> I'll reply within this thread when the modifications are applied to
> trunk.

Sorry for the delay, got busy with other things.

You'll find a preliminary patch in attachment. Can you test it and tell
me if it makes valgrind happy before I apply it to trunk?

Cheers,
Julien.

-- 
Julien Kerihuel
[email protected]
OpenChange Project Manager

GPG Fingerprint: 0B55 783D A781 6329 108A  B609 7EF6 FE11 A35F 1F79

Index: libmapi/emsmdb.c
===================================================================
--- libmapi/emsmdb.c	(revision 1288)
+++ libmapi/emsmdb.c	(working copy)
@@ -694,6 +694,7 @@
 
 		data = pull_emsmdb_property(mem_ctx, lp_ctx, &offset, tags->aulPropTag[i_tag], content);
 		if (data) {
+			talloc_steal(*propvals, data);
 			p_propval = &((*propvals)[i_propval]);
 			p_propval->ulPropTag = tags->aulPropTag[i_tag];
 			p_propval->dwAlignPad = 0x0;
@@ -780,6 +781,7 @@
 			if (havePropertyValue) {
 				lpProps[prop].dwAlignPad = 0x0;
 				data = pull_emsmdb_property(mem_ctx, lp_ctx, &offset, lpProps[prop].ulPropTag, content);
+				talloc_steal(lpProps, data);
 				set_SPropValue(&lpProps[prop], data);
 			}
 		}
@@ -835,6 +837,7 @@
 		} 
 
 		data = pull_emsmdb_property(mem_ctx, lp_ctx, &offset, aulPropTag, content);
+		talloc_steal(aRow->lpProps, data);
 		aRow->lpProps[i].ulPropTag = aulPropTag;
 		aRow->lpProps[i].dwAlignPad = 0x0;
 		set_SPropValue(&(aRow->lpProps[i]), data);
Index: libmapi/IMsgStore.c
===================================================================
--- libmapi/IMsgStore.c	(revision 1288)
+++ libmapi/IMsgStore.c	(working copy)
@@ -527,10 +527,16 @@
 		SRowSet->aRow[i].lpProps[0].dwAlignPad = 0x0;
 		SRowSet->aRow[i].lpProps[0].value.d = reply->entries[i].fid;
 
-		SRowSet->aRow[i].lpProps[1].ulPropTag = PR_MESSAGE_CLASS;
-		SRowSet->aRow[i].lpProps[1].dwAlignPad = 0x0;
-		SRowSet->aRow[i].lpProps[1].value.lpszA = talloc_strdup((TALLOC_CTX *)SRowSet->aRow, reply->entries[i].lpszMessageClass);
-	
+		if (reply->entries[i].lpszMessageClass && strlen(reply->entries[i].lpszMessageClass)) {
+			SRowSet->aRow[i].lpProps[1].ulPropTag = PR_MESSAGE_CLASS;
+			SRowSet->aRow[i].lpProps[1].dwAlignPad = 0x0;
+			SRowSet->aRow[i].lpProps[1].value.lpszA = talloc_strdup((TALLOC_CTX *)SRowSet->aRow[i].lpProps, reply->entries[i].lpszMessageClass);
+		} else {
+			SRowSet->aRow[i].lpProps[1].ulPropTag = PR_MESSAGE_CLASS;
+			SRowSet->aRow[i].lpProps[1].dwAlignPad = 0x0;
+			SRowSet->aRow[i].lpProps[1].value.lpszA = "";
+		}
+
 		SRowSet->aRow[i].lpProps[2].ulPropTag = PR_LAST_MODIFICATION_TIME;
 		SRowSet->aRow[i].lpProps[2].dwAlignPad = 0x0;
 		SRowSet->aRow[i].lpProps[2].value.ft.dwLowDateTime = reply->entries[i].modiftime.dwLowDateTime;
Index: libmapi/IMAPITable.c
===================================================================
--- libmapi/IMAPITable.c	(revision 1288)
+++ libmapi/IMAPITable.c	(working copy)
@@ -290,7 +290,7 @@
 	reply = &mapi_response->mapi_repl->u.mapi_QueryRows;
 	rowSet->cRows = reply->RowCount;
 	rowSet->aRow = talloc_array((TALLOC_CTX *)table, struct SRow, rowSet->cRows);
-	emsmdb_get_SRowSet((TALLOC_CTX *)table, global_mapi_ctx->lp_ctx, rowSet, &table->proptags, &reply->RowData);
+	emsmdb_get_SRowSet((TALLOC_CTX *)rowSet->aRow, global_mapi_ctx->lp_ctx, rowSet, &table->proptags, &reply->RowData);
 
 	talloc_free(mapi_response);
 	talloc_free(mem_ctx);

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
devel mailing list
[email protected]
http://mailman.openchange.org/listinfo/devel

Reply via email to