Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-133269

QTextStream: suspicious negation when streaming numbers

    XMLWordPrintable

Details

    • 3
    • 5a230596c (dev), 055b5a83b (6.9), 9c59689de (6.8), 3d71e69a7 (tqtc/lts-6.5), 44ddb34da (dev), 05b91b119 (6.9), 7a2e24a07 (tqtc/lts-5.15), 051518320 (6.8), 9e7e3be21 (tqtc/lts-6.5), a35a46a4d (tqtc/lts-5.15)
    • Foundation Sprint 124, Foundation Sprint 125

    Description

      In qtextstream.cpp there's:

      void QTextStreamPrivate::putNumber(qulonglong number, bool negative)
      {
      ...
          if (negative && base == 10) {
              result = dd->longLongToString(-static_cast<qlonglong>(number), -1,
                                            base, -1, flags);
      

      If the cast results in LLONG_MIN, the subsequent negation (unary -) is UB. Probably the same code can be rewritten...?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Eddy Edward Welbourne
            peppe Giuseppe D'Angelo
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: