Loading ...
Sorry, an error occurred while loading the content.

[patch] possible bug in gui_mch_init() in gui_gtk_x11.c

Expand Messages
  • Ken Takata
    Hi, ... +++ b/src/gui_gtk_x11.c @@ -3163,7 +3163,7 @@ # if defined(FEAT_FLOAT) && defined(LC_NUMERIC) /* Make sure strtod() uses a decimal point, not a comma.
    Message 1 of 5 , Apr 17, 2014
    • 0 Attachment
      Hi,

      Clang warns this:

      --- a/src/gui_gtk_x11.c
      +++ b/src/gui_gtk_x11.c
      @@ -3163,7 +3163,7 @@
      # if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
      /* Make sure strtod() uses a decimal point, not a comma. Gnome init
      * may change it. */
      - if (setlocale(LC_NUMERIC, NULL) != (char *) "C")
      + if (strcmp(setlocale(LC_NUMERIC, NULL), "C") != 0)
      setlocale(LC_NUMERIC, "C");
      # endif
      }

      Regards,
      Ken Takata

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • Bram Moolenaar
      ... Good catch. Has gone unnoticed for a long time. -- I got a new desk stapler. It broke on the first desk I tried. /// Bram Moolenaar -- Bram@Moolenaar.net
      Message 2 of 5 , Apr 17, 2014
      • 0 Attachment
        Ken Takata wrote:

        > Clang warns this:
        >
        > --- a/src/gui_gtk_x11.c
        > +++ b/src/gui_gtk_x11.c
        > @@ -3163,7 +3163,7 @@
        > # if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
        > /* Make sure strtod() uses a decimal point, not a comma. Gnome init
        > * may change it. */
        > - if (setlocale(LC_NUMERIC, NULL) != (char *) "C")
        > + if (strcmp(setlocale(LC_NUMERIC, NULL), "C") != 0)
        > setlocale(LC_NUMERIC, "C");
        > # endif
        > }

        Good catch. Has gone unnoticed for a long time.

        --
        I got a new desk stapler. It broke on the first desk I tried.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ an exciting new programming language -- http://www.Zimbu.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • Cade Forester
        ... strcmp() cause segmentation fault for NULL pointer -- diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c ... +++ b/src/gui_gtk_x11.c @@ -3144,7 +3144,8 @@
        Message 3 of 5 , Apr 18, 2014
        • 0 Attachment
          > + if (strcmp(setlocale(LC_NUMERIC, NULL), "C") != 0)

          strcmp() cause segmentation fault for NULL pointer

          --

          diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
          --- a/src/gui_gtk_x11.c
          +++ b/src/gui_gtk_x11.c
          @@ -3144,7 +3144,8 @@
          # if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
          /* Make sure strtod() uses a decimal point, not a comma. Gnome init
          * may change it. */
          - if (setlocale(LC_NUMERIC, NULL) != (char *) "C")
          + char *s = setlocale(LC_NUMERIC, NULL);
          + if (strcmp((s==NULL)?"":s, "C") != 0)
          setlocale(LC_NUMERIC, "C");
          # endif
          }

          --
          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • Nikolay Pavlov
          ... init ... Why do you compare a known string with a known string here? You should use something like if(s == NULL || STRCMP(s, C ) != 0). Also note that vim
          Message 4 of 5 , Apr 18, 2014
          • 0 Attachment


            On Apr 18, 2014 7:28 PM, "Cade Forester" <ahx2323@...> wrote:
            >
            > > +     if (strcmp(setlocale(LC_NUMERIC, NULL), "C") != 0)
            >
            > strcmp() cause segmentation fault for NULL pointer
            >
            > --
            >
            > diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
            > --- a/src/gui_gtk_x11.c
            > +++ b/src/gui_gtk_x11.c
            > @@ -3144,7 +3144,8 @@
            >  # if defined(FEAT_FLOAT) && defined(LC_NUMERIC)
            >         /* Make sure strtod() uses a decimal point, not a comma. Gnome init
            >          * may change it. */
            > -       if (setlocale(LC_NUMERIC, NULL) != (char *) "C")
            > +       char *s = setlocale(LC_NUMERIC, NULL);
            > +       if (strcmp((s==NULL)?"":s, "C") != 0)

            Why do you compare a known string with a known string here? You should use something like if(s == NULL || STRCMP(s, "C") != 0). Also note that vim uses STRCMP macro all over the place, not strcmp.

            >            setlocale(LC_NUMERIC, "C");
            >  # endif
            >      }
            >
            > --
            > --
            > You received this message from the "vim_dev" maillist.
            > Do not top-post! Type your reply below the text you are replying to.
            > For more information, visit http://www.vim.org/maillist.php
            >
            > ---
            > You received this message because you are subscribed to the Google Groups "vim_dev" group.
            > To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
            > For more options, visit https://groups.google.com/d/optout.

            --
            --
            You received this message from the "vim_dev" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_dev" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          • Bram Moolenaar
            ... Thanks for catching that. [Appropriate furtune included by coincidence :-)] -- Thou shalt not follow the Null Pointer, for at its end Chaos and Madness
            Message 5 of 5 , Apr 18, 2014
            • 0 Attachment
              Cade Forester wrote:

              > > + if (strcmp(setlocale(LC_NUMERIC, NULL), "C") != 0)
              >
              > strcmp() cause segmentation fault for NULL pointer

              Thanks for catching that.

              [Appropriate furtune included by coincidence :-)]

              --
              "Thou shalt not follow the Null Pointer, for at its end Chaos and
              Madness lie."

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ an exciting new programming language -- http://www.Zimbu.org ///
              \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

              --
              --
              You received this message from the "vim_dev" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php

              ---
              You received this message because you are subscribed to the Google Groups "vim_dev" group.
              To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
              For more options, visit https://groups.google.com/d/optout.
            Your message has been successfully submitted and would be delivered to recipients shortly.