1. 16 Mar, 2016 - 15 commits
  2. 15 Mar, 2016 - 12 commits
    • Joerg Bornemann's avatar
      Remove handle duplication code from QWindowsPipeWriter · 5393ba97
      Joerg Bornemann authored
      
      There is no apparent reason why the handle should be duplicated.
      
      Change-Id: I8ff2cde2f050934ed0dd9ab2d39a1b1efa327a17
      Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
      5393ba97
    • Shawn Rutledge's avatar
      xcb: Initialize all xcb_client_message_event_t members before use · 6c53f252
      Shawn Rutledge authored
      
      Change-Id: I01e4b69b138fd19fc7e67751d93adebc1326b2f9
      Reviewed-by: default avatarOrgad Shaneh <orgads@gmail.com>
      6c53f252
    • Marc Mutz's avatar
      QRect: fix UB (int overflow) in center() · e4c6d73f
      Marc Mutz authored
      
      QRect::center() should be defined for any
        QRect(x1,y1,x2,x2), INT_MIN <= x1, x2, y1, y2 <= INT_MAX
      because the average of two signed integers is always
      representable as a signed integer.
      
      But not when it's calculated as (x1+x2)/2, since that
      expression overflows when x1 > INT_MAX - x2.
      
      Instead of playing games with Hacker's Delight-style
      expressions, or use Google's patented algorithm, which
      requires two divisions, take advantage of the fact that
      int is not intmax_t and perform the calculation in the
      qint64 domain. The cast back to int is always well-
      defined since, as mentioned, the result is always
      representable in an int.
      
      Fix a test-case that expected a nonsensical result due
      to overflow.
      
      [ChangeLog][QtCore][QRect] Fixed integer overflow in
      center(). This fixes the result for some corner-cases
      like a 1x1 rectangle at (INT_MIN, INT_MIN), for which
      the previous implementation could return anything
      (due to invoking undefined behavior), but commonly
      returned (0, 0).
      
      Change-Id: I1a885ca6dff770327dd31655c3eb473fcfeb8878
      Reviewed-by: default avatarLars Knoll <lars.knoll@theqtcompany.com>
      e4c6d73f
    • Morten Johan Sørvig's avatar
      Compile with -no-opengl · 1dcc53f6
      Morten Johan Sørvig authored
      
      QCocoaBackingstore::toImage() can only be Q_DECL_OVERRIDE
      if QPlatformBackingStore::toImage() is present, which
      it isn’t for NO_OPENGL builds.
      
      Change-Id: Ib116f40fd26defb29a8d520d3e3fb104d8da8d57
      Task-number: QTBUG-51694
      Reviewed-by: default avatarTimur Pocheptsov <timur.pocheptsov@theqtcompany.com>
      1dcc53f6
    • Marc Mutz's avatar
      tst_QRect: drop a test that depends on int overflow · 5784c064
      Marc Mutz authored
      
      The compiler can statically check that this is undefined
      behavior:
      
        tst_qrect.cpp:3173:52: warning: integer overflow in expression [-Woverflow]
                     << QRect(QPoint(0,0), QPoint(INT_MAX+(0-INT_MIN),INT_MAX+(0-INT_MIN)));
                                                         ~^~
        tst_qrect.cpp:3173:72: warning: integer overflow in expression [-Woverflow]
                     << QRect(QPoint(0,0), QPoint(INT_MAX+(0-INT_MIN),INT_MAX+(0-INT_MIN)));
                                                                             ~^~
      
      Fix by skipping the test (like most of the others are
      in the block).
      
      Change-Id: I359a5e16db6c660c9f11d7dd8fbb40730bd63887
      Reviewed-by: default avatarLars Knoll <lars.knoll@theqtcompany.com>
      5784c064
    • Marc Mutz's avatar
      Revert "Handle the QWidgetPrivate::mapper structure" · b4fa18a9
      Marc Mutz authored
      
      This reverts commit 90de48493be283b9afb249f6a0fd8dbd8958517d.
      
      The call isn't necessary, but invokes undefined behavior.
      
      It invokes undefined behavior because deleteTLSysExtra() is called
      from deleteExtra(), which is called from ~QWidgetPrivate(), which is
      called from ~QObject(). Thus, by the time we call q->windowType()
      within setWinId(), q is no longer a QWidget, but only a QObject, and
      calling a QWidget member function then is UB.
      
      UBSan confirms:
      
        qwidget_p.h:300:5: runtime error: downcast of address 0x2afdd4053620 which does not point to an object of type 'QWidget' (the Q_Q macro)
        0x2afdd4053620: note: object is of type 'QObject'
        qwidget.cpp:1712:93: runtime error: member call on address 0x2afdd4053620 which does not point to an object of type 'QWidget'
        0x2afdd4053620: note: object is of type 'QObject'
      
      It is also unnecessary:
      
      deleteTLSysExtra() is called from two places: QWidget::destroy() and
      deleteExtra(). deleteExtra() is only called from ~QWidgetPrivate()
      which is only called from ~QObject() called by ~QWidget(), which,
      however, already calls QWidget::destroy(). QWidget::destroy(), in
      turn, unconditionally (for non-desktop widgets, at least) calls
      setWinId(0) itself.
      
      So fix the UB by removing the call without replacement.
      
      Conflicts:
      	src/gui/kernel/qwidget_qpa.cpp
      
      Change-Id: Ib3a8cc9d28a096183f1d3dfd1941ea5fdc6a4aac
      Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>
      b4fa18a9
    • Marc Mutz's avatar
      QRawFont: fix UB (misaligned load) in fontTable() · 9739cae4
      Marc Mutz authored
      
      Found by UBSan:
      
        qrawfont.cpp:618:60: runtime error: load of misaligned address 0x2acee92a5569 for type 'const quint32', which requires 4 byte alignment
      
      Fix by using MAKE_TAG(), like everywhere else, instead
      of a load through a type-punned and misaligned pointer.
      
      Change-Id: I52b88ca05a57f7d8c5e5bce953384de49514079b
      Reviewed-by: default avatarKonstantin Ritt <ritt.ks@gmail.com>
      Reviewed-by: default avatarLars Knoll <lars.knoll@theqtcompany.com>
      9739cae4
    • Marc Mutz's avatar
      tst_QSqlQuery: fix UBs (invalid downcasts, member calls) · add95c55
      Marc Mutz authored
      
      The existing code derived a helper class from QSqlResult and
      overloaded two protected functions as public ones so the test
      could call them after casting QSqlResults to that helper class.
      
      Both the cast (which is a C-style cast, but with combined
      static_cast and const_cast semanics) and the following member
      function call are undefined behavior.
      
      Fix by making the test class a friend of QSqlResult, and
      dropping the casts.
      
      Change-Id: I09de2e2b46976d01cfce25892aec6ad36881d3eb
      Reviewed-by: default avatarMark Brand <mabrand@mabrand.nl>
      add95c55
    • Marc Mutz's avatar
      QCosmeticStroker: fix several UBs involving << with a negative LHS · 52a599bb
      Marc Mutz authored
      
      Left-shifts of negative values are undefined in C++. In particular,
      they don't behave arithmetically.
      
      Reported by UBSan:
      
        qcosmeticstroker.cpp: 72:15: runtime error: left shift of negative value -14/-19/-32/-33/-34/-37/-38/-63/-64/-192/-384/-1280
        qcosmeticstroker.cpp:444:20: runtime error: left shift of negative value -64
        qcosmeticstroker.cpp:451:26: runtime error: left shift of negative value -1
        qcosmeticstroker.cpp:483:26: runtime error: left shift of negative value -1
        qcosmeticstroker.cpp:762:20: runtime error: left shift of negative value -64
        qcosmeticstroker.cpp:774:26: runtime error: left shift of negative value -1
        qcosmeticstroker.cpp:813:47: runtime error: left shift of negative value -1
        qcosmeticstroker.cpp:839:20: runtime error: left shift of negative value -64
        qcosmeticstroker.cpp:851:26: runtime error: left shift of negative value -1
        qcosmeticstroker.cpp:889:47: runtime error: left shift of negative value -1
        qcosmeticstroker.cpp:932:27: runtime error: left shift of negative value -64
        qcosmeticstroker.cpp:995:27: runtime error: left shift of negative value -3/-64
      
      Fix by using ordinary multiplication instead, because negative
      left-hand-side values don't look like they are an error.
      
      Change-Id: Icbebd41f6ddd3dca4abd385585fc0f82064fe8b6
      Reviewed-by: default avatarAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>
      52a599bb
    • Milla Pohjanheimo's avatar
      Remove restoreDockWidget from BLACKLIST · 1a9e1fbb
      Milla Pohjanheimo authored
      
      Tested on the Ubuntu 14.04 VM. The test didn't fail anymore with
      2000 test rounds
      
      Change-Id: Ic12c60e5ebf9c234358a6983bf87fa0a88d7886e
      Reviewed-by: default avatarTony Sarajärvi <tony.sarajarvi@theqtcompany.com>
      1a9e1fbb
    • Błażej Szczygieł's avatar
      Remove Qt::WA_OutsideWSRange flag even if the widget is not yet visible. · 11836be1
      Błażej Szczygieł authored
      
      Show the widget when its initial size is 0 and the layout changes the
      size during showing.
      
      Task-number: QTBUG-51788
      Change-Id: I3251ac27328f9715ff13d96e1b82fbf824d9e79d
      Reviewed-by: default avatarDmitry Shachnev <mitya57@gmail.com>
      Reviewed-by: default avatarShawn Rutledge <shawn.rutledge@theqtcompany.com>
      11836be1
    • Morten Johan Sørvig's avatar
      Cocoa: Fix crash on screen disconnect. · c4886ca4
      Morten Johan Sørvig authored
      
      Maintain virtual siblings list on screen deletion.
      
      QCocoaIntegration::updateScreens() has a loop which
      will delete all non-current QScreen objects using
      QPlatformIntegration::destroyScreen().
      
      destroyScreen() vill eventually call QWindowPrivate::
      setTopLevelScreen() which accesses the virtual siblings
      list for the deleted screen.
      
      This can cause a stale pointer access if the virtual
      screen list is not up to date, especially when disconnecting
      two screens at the same time.
      
      Change-Id: Ia6b9d01edf8e5eea25b64604a2b3b28b173125f7
      Task-number: QTBUG-48275
      Reviewed-by: default avatarTimur Pocheptsov <timur.pocheptsov@theqtcompany.com>
      Reviewed-by: default avatarMorten Johan Sørvig <morten.sorvig@theqtcompany.com>
      c4886ca4
  3. 14 Mar, 2016 - 1 commit
    • Antonio Larrosa's avatar
      Don't include by default ciphers that are not supported · 063ad1c8
      Antonio Larrosa authored
      
      There could be cases (mostly when compiled on old systems, since modern
      openssl versions don't include such insecure ciphers) in which
      defaultCiphers included a cipher that wasn't in the supported ciphers
      list. With this patch we make sure that defaultCiphers is a subset of
      supportedCiphers
      
      Change-Id: I545ea21f5fd3a6ed13b366cdd56a1393233f9fc9
      Reviewed-by: default avatarRichard J. Moore <rich@kde.org>
      063ad1c8
  4. 13 Mar, 2016 - 1 commit
  5. 12 Mar, 2016 - 1 commit
    • Marc Mutz's avatar
      QNetworkHeaders: fix UB (invalid enum value) in Private::parseAndSetHeader() · 978804d2
      Marc Mutz authored
      
      Found by UBSan:
      
        qnetworkrequest.cpp:1016:19: runtime error: load of value 4294967295, which is not a valid value for type 'KnownHeaders'
      
      KnownHeaders does not contain a failure state, and no negative
      values. -1 is therefore not a valid value for an object of type
      KnownHeaders, so loading one is considered UB.
      
      Fix by returning the result of parseHeaderName() as an int,
      only casting to KnownHeaders after checking for the failure
      case.
      
      Change-Id: I6b165fe2b15c747344a9b2750bb753582c5bcbeb
      Reviewed-by: default avatarRichard J. Moore <rich@kde.org>
      978804d2
  6. 11 Mar, 2016 - 6 commits
  7. 10 Mar, 2016 - 4 commits