#264 wrong string compare in api _Stl_loc_combine_names of locale.cpp

5.2
closed-fixed
None
5
2014-07-03
2014-07-01
No

Dear Petr Ovtchenkov,

I am looking into issues in stlport using static analyzer.
I checked there is an issue in stlport locale.cpp with respect to string compare api in function _Stl_loc_combine_names

stlport/src/locale.cpp

static void _Stl_loc_combine_names(_Locale_impl* L,

                               const char* name1, const char* name2,
                               locale::category c) {

//Issue : Pointless string comparison (CONSTANT_EXPRESSION_RESULT)
//pointless_string_compare: strcmp(name1, name1) is always 0 because name1 is compared against itself.

if ((c & locale::all) == 0 || strcmp(name1, name1) == 0)
L->name = name1;
else if ((c & locale::all) == locale::all)
L->name = name2;
else {
_Stl_loc_combine_names_aux(L, name1, name2, name2, name2, name2, name2, name2, c);
}
}

Please check the below patch file to fix the issue.

--- locale.cpp 2014-07-01 14:13:40.793721577 +0530
+++ locale_patch.cpp 2014-07-01 14:14:17.701720420 +0530
@@ -207,7 +207,7 @@
static void _Stl_loc_combine_names(_Locale_impl L,
const char
name1, const char* name2,
locale::category c) {
- if ((c & locale::all) == 0 || strcmp(name1, name1) == 0)
+ if ((c & locale::all) == 0 || strcmp(name1, name2) == 0)
L->name = name1;
else if ((c & locale::all) == locale::all)
L->name = name2;

I request you to review the patch request and give your valuable comments.
and Merge if this fixes the issue.

Thanks & Regards,
Kuldeep Gupta

1 Attachments

Discussion

  • Petr Ovtchenkov

    Petr Ovtchenkov - 2014-07-01
    • status: open --> open-remind
     
  • Petr Ovtchenkov

    Petr Ovtchenkov - 2014-07-03

    "git format-patch" remains terra incognita for you. Nevertheless, it in STLport-5.2 branch.

     
  • Petr Ovtchenkov

    Petr Ovtchenkov - 2014-07-03
    • status: open-remind --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks