From 8a14b3bd0e03ebdb627823b37326c5493def343d Mon Sep 17 00:00:00 2001 From: Jean-Yves Avenard Date: Fri, 16 Dec 2016 16:20:06 +1100 Subject: [PATCH] Bug 1323847: P3. Don't allocate data for empty buffer. r=gerald MozReview-Commit-ID: I67RmFZpRDy --HG-- extra : rebase_source : 19dcb4530dd053dc4b8735d872a4cb2e7adc2a6e --- dom/media/MediaData.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dom/media/MediaData.h b/dom/media/MediaData.h index 98904e311afc..88c5e6d92711 100644 --- a/dom/media/MediaData.h +++ b/dom/media/MediaData.h @@ -220,6 +220,10 @@ private: // Returns false if memory couldn't be allocated. bool EnsureCapacity(size_t aLength) { + if (!aLength) { + // No need to allocate a buffer yet. + return true; + } const CheckedInt sizeNeeded = CheckedInt(aLength) * sizeof(Type) + AlignmentPaddingSize();