Log4cxx
  1. Log4cxx
  2. LOGCXX-30

StringTokenizer uses evil strtok and wcstok functions

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 0.9.7
    • Fix Version/s: 0.10.0
    • Component/s: Configurator
    • Labels:
      None

      Description

      Use of strtok and wcstok are discouraged, I quote from the man page for strtok:

      BUGS
      Never use these functions. If you do, note that:

      These functions modify their first argument.

      These functions cannot be used on constant strings.

      The identity of the delimiting character is lost.

      The strtok() function uses a static buffer while
      parsing, so it's not thread safe. Use strtok_r() if
      this matters to you.

      I discovered this after getting a report from valgrind that StringTokenizer used a delete where it should have used a delete [], however there is no reason just to fix that one problem.

      It should be trivial to rewrite using std::basic_string methods.

        Activity

        Hide
        Curt Arnold added a comment -

        CVS commit: http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4cxx-dev@logging.apache.org&msgNo=328

        Added test case for StringTokenizer and rewrote using STD string methods.

        Show
        Curt Arnold added a comment - CVS commit: http://nagoya.apache.org/eyebrowse/ReadMsg?listName=log4cxx-dev@logging.apache.org&msgNo=328 Added test case for StringTokenizer and rewrote using STD string methods.

          People

          • Assignee:
            Curt Arnold
            Reporter:
            Curt Arnold
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development