diff options
-rw-r--r-- | src/multimedia/video/qmemoryvideobuffer.cpp | 2 | ||||
-rw-r--r-- | tests/auto/unit/qvideoframe/tst_qvideoframe.cpp | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/multimedia/video/qmemoryvideobuffer.cpp b/src/multimedia/video/qmemoryvideobuffer.cpp index e05210d9d..febcd66c8 100644 --- a/src/multimedia/video/qmemoryvideobuffer.cpp +++ b/src/multimedia/video/qmemoryvideobuffer.cpp @@ -101,7 +101,7 @@ uchar *QMemoryVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine) { Q_D(QMemoryVideoBuffer); - if (d->mapMode == NotMapped && d->data.data() && mode != NotMapped) { + if (d->mapMode == NotMapped && d->data.size() && mode != NotMapped) { d->mapMode = mode; if (numBytes) diff --git a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp index bb77b7cca..e99c4bf77 100644 --- a/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp +++ b/tests/auto/unit/qvideoframe/tst_qvideoframe.cpp @@ -31,6 +31,7 @@ #include <QtTest/QtTest> #include <qvideoframe.h> +#include "private/qmemoryvideobuffer_p.h" #include <QtGui/QImage> #include <QtCore/QPointer> #include <QtMultimedia/private/qtmultimedia-config_p.h> @@ -89,6 +90,8 @@ private slots: void image_data(); void image(); + + void emptyData(); }; Q_DECLARE_METATYPE(QImage::Format) @@ -1299,6 +1302,15 @@ void tst_QVideoFrame::image() QCOMPARE(img.bytesPerLine(), bytesPerLine); } +void tst_QVideoFrame::emptyData() +{ + QByteArray data(nullptr, 0); + QVideoFrame f(new QMemoryVideoBuffer(data, 600), + QSize(800, 600), + QVideoFrame::Format_ARGB32); + QVERIFY(!f.map(QAbstractVideoBuffer::ReadOnly)); +} + QTEST_MAIN(tst_QVideoFrame) #include "tst_qvideoframe.moc" |