This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Dangling pointer in ICF from c_str method.


Made the changes and committed the patch.

Thanks,
-Sri.

On Wed, Feb 2, 2011 at 1:48 PM, Ian Lance Taylor <iant@google.com> wrote:
> Sriraman Tallam <tmsriram@google.com> writes:
>
>> 2011-02-02 ?Sriraman Tallam ?<tmsriram@google.com>
>>
>> ? ? ? * icf.h (is_section_foldable_candidate): Change type of parameter
>> ? ? ? ? to std::string.
>> ? ? ? * icf.cc (Icf::find_identical_sections): Change type of local variable
>> ? ? ? ? section_name to be std::string.
>> ? ? ? (is_function_ctor_or_dtor): Change type of parameter to std::string.
>
>> ?static bool
>> -is_function_ctor_or_dtor(const char* mangled_func_name)
>> +is_function_ctor_or_dtor(const std::string& section_name)
>> ?{
>> - ?if ((is_prefix_of("_ZN", mangled_func_name)
>> - ? ? ? || is_prefix_of("_ZZ", mangled_func_name))
>> - ? ? ?&& (is_gnu_v3_mangled_ctor(mangled_func_name)
>> - ? ? ? ? ?|| is_gnu_v3_mangled_dtor(mangled_func_name)))
>> + ?const char* mangled_func_name = strrchr(section_name.c_str(), '.');
>> + ?gold_assert (mangled_func_name != NULL);
>
> No space before parenthesis.
>
>> @@ -696,7 +697,7 @@ Icf::find_identical_sections(const Input
>>
>> ? ? ? ?for (unsigned int i = 0;i < (*p)->shnum(); ++i)
>> ? ? ? ? ?{
>> - ? ? ? const char* section_name = (*p)->section_name(i).c_str();
>> + ? ? ? const std::string& section_name = (*p)->section_name(i);
>
> Make this a normal variable rather than a reference. ?That is, drop the
> '&'. ?I think your code is correct but there is no need for a reference
> here; RVO should apply, I think.
>
> This is OK with those changes.
>
> Thanks.
>
> Ian
>

Attachment: gold_patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]