[PATCH 01/24] lib/message.cc: stale pointer bug
Jani Nikula
jani at nikula.org
Thu May 2 13:36:30 PDT 2013
On Thu, 02 May 2013, Tomi Ollila <tomi.ollila at iki.fi> wrote:
> On Thu, May 02 2013, Vladimir Marek <Vladimir.Marek at Oracle.COM> wrote:
>
>>> > int prefix_len = strlen (prefix);
>>> > - const char *term = NULL;
>>> > + std::string term;
>>> > char *value;
>>> >
>>> > i.skip_to (prefix);
>>> >
>>> > - if (i != end)
>>> > - term = (*i).c_str ();
>>> > + if (i == end)
>>> > + return NULL;
>>> >
>>> > - if (!term || strncmp (term, prefix, prefix_len))
>>> > + term = *i;
>>>
>>> ... hmm, a raii(?) solution above would be std::string term = *i;
>>
>> I'm not sure what's raii (I'm not very good at c++ ...), but I guess you
>> mean to use 'std::string term = *i;' to avoid copy constructor. That
>> surely is a good idea. Let me rework the patch!
>
> I am not that smart (i.e. avoid copy constructor it might be, I don't
> know...) I am lousy in c++. I attempter to mean
> http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
> in a sense that when variable is introduced it is also initialized
> to useful value (so that no-one accidentally add code between introduction
> and initialization).
>
> Anyway, if you rework the patch then we can vote which version to
> apply (yeah, sure >;)
I already dropped needs-review from the latest version [1]. I'm curious
about patches 2-24, let's not stall here. ;)
Jani.
[1] id:1367505102-12860-1-git-send-email-Vladimir.Marek at oracle.com
More information about the notmuch
mailing list