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

QString::fromWCharArray triggers the assertion: "(misalignment & 1) == 0"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 6.5.0 Beta3
    • None
    • Windows

    Description

      I received data from a socket which contains string data with offset. When I call QString::fromWCharArray the assertion triggered, and when I switch to QString::fromStdWString everything works fine.

      ASSERT: "(misalignment & 1) == 0" in file C:\Users\qt\work\qt\qtbase\src\corelib\text\qstring.cpp, line 414

       

      void qstring_fromwchararray_test()
      {
          struct StructA
         

      {         quint8 type;     }

      ;
          struct StructB
         

      {         wchar_t text[32];     }

      ;
          char buf[sizeof(StructA) + sizeof(StructB)];
          auto sa = (StructA*)buf;
          auto sb = (StructB*)&buf[sizeof(StructA)];
          sa->type = 1;
          memset(sb->text, 0, sizeof(sb->text));
          wcscpy_s(sb->text, L"test string.");
          QString qtext = QString::fromWCharArray(sb->text); // crash
          qDebug() << qtext;
      }

      Attachments

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              gearstatic Xylo Nite
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes