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

Comparing of memory chunks with garbage

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 4.7.4
    • 4.7.1
    • None
    • All major platforms supported by Qt.
    • 95aa4e4f9b82c3652ffc93310b190db869d491df

      Declarative module creates dynamic meta object data in heap, allocating chunk of memory and casting it to appropriate class with reinterpret_cast. Because such chunks never being cleaned (for instance with memset) and class members are aligned - chunk of memory will still contain uninitialized bytes. This leads to potential undefined behavior when comparing such chunks with memcmp in hope that they will be equal. But they will not if class instance has been copied using copy constructor or operator=.

      Valgrind triggers several "jump on uninitialized value" errors.
      At least if uninitialized memory chunks are ok exactly this cases - they should be cleaned anyway to help to locate real errors.

      Example of such comparing:
      In qdeclarativecompileddata.cpp:
      int QDeclarativeCompiledData::indexForByteArray(const QByteArray &data)

      Hot to fix:
      In qmetaobjectbuilder.cpp:
      Add memset(buf, 0, size).
      Here: QByteArray QMetaObjectBuilder::toRelocatableData(bool *ok) const
      And here: QMetaObject *QMetaObjectBuilder::toMetaObject() const

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

            martjone Martin Jones (closed Nokia identity) (Inactive)
            dendy Daniel Levin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes