CVPixelBufferGetBytePointerCallback should check for CVPixelBufferGetBaseAddress returning nullptr
https://bugs.webkit.org/show_bug.cgi?id=241845
rdar://95622853
Patch by Youenn Fablet <youennf@gmail.com> on 2022-06-22
Reviewed by Eric Carlson.
CVPixelBufferGetBaseAddress may return nullptr in some cases.
In that case, return early.
* Source/WebCore/platform/graphics/cv/PixelBufferConformerCV.cpp:
(WebCore::CVPixelBufferGetBytePointerCallback):
Canonical link: https://commits.webkit.org/251739@main
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@295734 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/platform/graphics/cv/PixelBufferConformerCV.cpp b/Source/WebCore/platform/graphics/cv/PixelBufferConformerCV.cpp
index ac5b1fb..bf263f1 100644
--- a/Source/WebCore/platform/graphics/cv/PixelBufferConformerCV.cpp
+++ b/Source/WebCore/platform/graphics/cv/PixelBufferConformerCV.cpp
@@ -70,6 +70,12 @@
++info->lockCount;
void* address = CVPixelBufferGetBaseAddress(info->pixelBuffer.get());
+ if (!address) {
+ RELEASE_LOG_ERROR(Media, "CVPixelBufferGetBaseAddress returned null");
+ RELEASE_LOG_STACKTRACE(Media);
+ return nullptr;
+ }
+
size_t byteLength = CVPixelBufferGetBytesPerRow(info->pixelBuffer.get()) * CVPixelBufferGetHeight(info->pixelBuffer.get());
verifyImageBufferIsBigEnough(address, byteLength);