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

QByteArray::resize throws std::bad:alloc if asked to allocate std::numeric_limits<int>::max()

    XMLWordPrintable

Details

    • Linux/X11
    • b321559a22a3ee6490695ecb9d95d3c9fbf7ee1c

    Description

      The following code

      #include <QByteArray>
      #include <QDebug>

      int main(int argc, char *argv[])

      {     QByteArray ba;     ba.resize(std::numeric_limits<int>::max());     qDebug() << ba.size(); }

       

      crashes with

      terminate called after throwing an instance of 'std::bad_alloc'
      what(): std::bad_alloc

       

      I've been told "it is known" that the max size QByteArray can hold is 2^31 but i can't find anything in the documentation.

       

      It would be nice if one could have a QByteArray::maxsize or something that could be used for that.

       

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            tsdgeos_kdab Albert Astals Cid
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes