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?
Here is a snippet of my test code:
mapi_session* session = NULL;
MapiLogonEx(&session, argv[1], NULL);
mapi_object_t obj_store;
mapi_object_init(&obj_store);
OpenMsgStore(session, &obj_store);
SPropTagArray tagArray;
tagArray.aulPropTag = new MAPITAGS[10];
tagArray.aulPropTag[0] = PR_DISPLAY_NAME;
tagArray.cValues = 1;
uint32 nProps;
SPropValue* props = NULL;
::GetProps(&obj_store, &tagArray, &props, &nProps);
MAPIFreeBuffer(props);
delete[] tagArray.aulPropTag;
And here is a snippet of the valgrind log
==31065== 124 bytes in 1 blocks are definitely lost in loss record 9 of 20
==31065== at 0x4C265AE: malloc (vg_replace_malloc.c:207)
==31065== by 0x65FAA56: __talloc (in /usr/local/samba/lib/libdcerpc.so.0.0.1)
==31065== by 0x65FAE01: _talloc_named_const (in
/usr/local/samba/lib/libdcerpc.so.0.0.1)
==31065== by 0x65FBF53: _talloc_realloc (in
/usr/local/samba/lib/libdcerpc.so.0.0.1)
==31065== by 0x65FD2B1: _talloc_realloc_array (in
/usr/local/samba/lib/libdcerpc.so.0.0.1)
==31065== by 0x65E2BFB: iconv_talloc (charcnv.c:187)
==31065== by 0x65E3174: convert_string_talloc_convenience (charcnv.c:327)
==31065== by 0x64AB9C5: ndr_pull_string (ndr_string.c:249)
==31065== by 0x5E1D3B9: pull_emsmdb_property (emsmdb.c:587)
==31065== by 0x5E1D97B: emsmdb_get_SPropValue (emsmdb.c:695)
==31065== by 0x5E031B9: GetProps (IMAPIProp.c:147)
==31065== by 0x40205A: main (fetchmail.cpp:167)
line 167 in fetchmail.cpp is
::GetProps(&obj_store, &tagArray, &props, &nProps);
Memory for the returned SPropValue is being allocated in emsmdb_get_SPropValue
and will be correctly freed by MAPIFreeBuffer. However, no pointers inside the
SPropValue array are freed.
> From: [email protected]
> To: [email protected]; [email protected]
> Subject: Re: [openchange][devel] How to correctly free the properties
> returned by GetProps and GetPropsAll
> Date: Fri, 20 Mar 2009 18:20:35 +1100
>
> On Friday 20 March 2009 02:42:09 am Chuck Bohling wrote:
> > With windows client MAPI, the props returned by IMAPIProp::GetProps are
> > freed with a single call to MAPIFreeBuffer. That does not seem to be the
> > case with OpenChange GetProps and GetPropsAll. What is the correct way free
> > the props so that there are no resource leaks?
> MAPIFreeBuffer should do it.
>
> We do have a few examples, although I won't promise that they are all
> perfect,
> it is a bug if they don't clean up properly. The simplest example I can think
> of is the mapitest GetProps / GetPropsAll tests, which you'll find in
> utils/mapitest/modules/module_oxcprpt.c
>
> Alternatively, if you can show us the code you're working on, and the
> valgrind
> (or equivalent) report, that might help.
>
> Brad
>
_________________________________________________________________
Windows Live⢠SkyDrive: Get 25 GB of free online storage.
http://windowslive.com/online/skydrive?ocid=TXT_TAGLM_WL_skydrive_032009
_______________________________________________
devel mailing list
[email protected]
http://mailman.openchange.org/listinfo/devel