ofxXmlSettings leak

Howdy. I found another leak, this time in ofxXmlSettings.

I’ve spent the past hour trying to find exactly how to stop this leak, but with no luck. Maybe someone else can see what’s wrong here? According to the developer tools, the leak is situated somewhere around here:

string ofxXmlSettings::getValue(string tag, string defaultValue, int which){  
	// lots of char *, string kung-fu here...  
	char * tempStr = new char[MAX_TAG_VALUE_LENGTH_IN_CHARS];  
	memset(tempStr, 0, MAX_TAG_VALUE_LENGTH_IN_CHARS);  
	char * returnPtr = (char *) defaultValue.c_str();  
	if (readTag(tag, tempStr, which)){  
		returnPtr = tempStr;  
	string returnString(returnPtr);  
	delete tempStr;  
	return returnString;  

The leak has something to do obviously with the new and delete, but I can’t figure out how to fix it. I tried making the following change:

delete[] tempStr;  

…which seems to me more logical, but it still doesn’t plug up the leak. Perhaps it’s because there is a reference to tempStr still hanging around in the heap (because of readTag()?), but I dunno.

As it turns out, there was another leak in that addon. I plugged it up by adding a destructor. I don’t know why it was left out, or if its absence was intentional; perhaps someone can verify this.

	storedHandle	= new TiXmlHandle(NULL);  
	delete storedHandle;  

It might seem minor to leave a long dangling, and it is, but if you call it enough, you’ll get yourself into trouble.