From: Gianni Tedesco Subject: Re: [PATCH,v2]: xl: don't free string literals Date: Wed, 8 Sep 2010 17:58:11 +0100 Message-ID: <1283965091.20276.182.camel@qabil.uk.xensource.com> References: <1283963489.20276.180.camel@qabil.uk.xensource.com> <1283964409.14311.1970.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1283964409.14311.1970.camel@zakaz.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Campbell Cc: Xen Devel , Ian Jackson List-Id: xen-devel@lists.xenproject.org On Wed, 2010-09-08 at 17:46 +0100, Ian Campbell wrote: > On Wed, 2010-09-08 at 17:31 +0100, Gianni Tedesco wrote: > > The function init_dm_info() is initialising some strings from literals. > > This is bad juju because when the destructor is called we cannot know if > > the string literal was overridden with a strdup()'d value. Therefore > > strdup values in the initialiser then introduce and use the function > > libxlu_cfg_replace_string() which free's whatever is set before > > strdupping the new value on top of it. The rule for the new call should > > be clear due to const vs. non-const arguments - changing the behaviour > > of libxlu_cfg_get_string() would cause more complexity than it saves. > > > > Signed-off-by: Gianni Tedesco > > About to bail for the day, but I guess this (untested) patch makes sense > on top of this? Yes, very much so > Avoids c_info->name being a string literal as well. Although I wonder if > maybe domain configurations with no name could just be rejected as > invalid? Having a whole bunch of domains called "test" doesn't seem > likely to be what anyone wants... Yeah, that looks suspect to me too. Gianni