Memory leak in soap_set_namespaces
Development toolkit for Web Services and XML data bindings for C & C++
Brought to you by:
engelen
When there are two consecutive calls to the function soap_set_namespaces there is a memory leak of whatever is contained on soap->local_namespaces.
soap_set_namespaces(struct soap *soap, const struct Namespace *p)
{ struct Namespace *ns = soap->local_namespaces;
struct soap_nlist *np, *nq, *nr;
unsigned int level = soap->level;
soap->namespaces = p;
soap->local_namespaces = NULL;
soap->local_namespaces is set to NULL without freeing the memory allocated on the last call.
I think it is a good idea to free whatever is contained on the pointer before setting it to NULL.
Regards,
Juan
You're forgetting that
nsis set to thelocal_namespacesand this is later used to copy and delete the data in that same block of code:Thank you for your fast response Robert.
You are right, the leak is not there. I think it is on the "soap_copy_context" function.
There you also have:
But that address was not stored and it is not deleted (because the copy object could have something prior to the copy on local_namespaces).
Anyways I am going to try to simplify what we did to reach this memory leak (shown by tcmalloc).
We are using gSOAP 2.8.27.
We create two NotificationServiceBindingService (lets call them "main" and "dup"), using the constructor
and then we call
And after deleting both objects we have a leak on soap->local_namespaces of dup
This leak doesn't show up if we manually free dup->soap->local_namespaces or if we call
before the copy.
Hope this make sense,
Juan