From 729ae0b417f65e78ea054b459ce089812da91e36 Mon Sep 17 00:00:00 2001 From: "Naram Qashat cyberbotx@cyberbotx.com" Date: Thu, 23 Oct 2008 02:24:34 +0000 Subject: [PATCH] Modified the Set() function in the character array version of ValueContainer to delete the old memory if the value is being reused, and to not allocate memory if there is no string to store. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1464 5417fbe8-f217-4b02-8779-1006273d7864 --- include/configreader.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/configreader.h b/include/configreader.h index 222195727..6db8f03dc 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -140,6 +140,11 @@ template<> class ValueContainer : public ValueContainerBase /** Change value to type T of size s */ void Set(const char *newval, size_t s) { + if (*val) delete [] *val; + if (!*newval) { + *val = NULL; + return; + } *val = new char[s]; strlcpy(*val, newval, s); }