I must warn that I don't have means to test if it works, whole this patch is based only on my programming experience. At least it compiles fine. I've found these bugs looking for something else:
1. If new is used, delete must be used somewhere else (but see comment below)
2. If strdup() is used, free() must be used somewhere else (but see comment below)
3. Using static variables in multithreaded program leads directly to big troubles
According to Publish() logic, free() and delete must not be called if the last parameter equals to false. However this parameter defaults to true and it is used so in this case.
I was working with CVS snapshot taken 2008.03.02.