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

QIODevice::read returns more than maxSize bytes (audioInput.start())

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P1: Critical P1: Critical
    • 4.7.2
    • 4.6.3, 4.7.0
    • Core: I/O, Multimedia
    • None
    • Debian Linux 2.6.32-5-686 #1 SMP Sat Sep 18 02:14:45 UTC 2010 i686 GNU/Linux
      Currently using Qt 4.7.0.

      Windows 7,
      Qt 4.7.0.
    • e3f1268e63064a54215051cf91d5f6b8c8bd4f0f, bfd87980bdc3d835723f429a3e4dbe2d884bca27

      According to the documentation, a call of
      qint64 QIODevice::read ( char * data, qint64 maxSize )
      should write no more than maxSize byte to *data.

      However, when the QIODevice is created with
      QIODevice* stream = audioInput.start();
      the call
      qint64 bytesRead = stream->read(buffer, 400);
      writes more than 400 byte to buffer (and the number > 400 is returned) if the time is long enough that the audio device has more than 400 byte to transfer. This behavior crashes programs that reserve 400 byte for the buffer.

      When debugging we realized that
      stream->read(buffer, 400);
      finally calles
      qint64 QAudioInputPrivate::read(char* data, qint64 len)
      in qaudioinput_alsa_p.cpp with len == 400.
      But in this function, len is not used Q_UNUSED(len) and all available bytes are read.

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

            denexter Andrew den Exter (closed Nokia identity) (Inactive)
            phispi Philipp Spitzer
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes