Guard against pSparseMemoryRequirements == NULL

While SwiftShader currently does not support the `sparseBinding` feature
it is valid to call vkGetImageSparseMemoryRequirements2() to query the
number of sparse memory requirements (which will be zero).

Bug: b/256051158
Change-Id: I9a237693bc5fabc9abe1ff92f5cf355be8f1a5e0
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/69454
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp
index 06e5e50..f8106f8 100644
--- a/src/Vulkan/libVulkan.cpp
+++ b/src/Vulkan/libVulkan.cpp
@@ -3546,11 +3546,14 @@
 		extInfo = extInfo->pNext;
 	}
 
-	const auto *extensionRequirements = reinterpret_cast<const VkBaseInStructure *>(pSparseMemoryRequirements->pNext);
-	while(extensionRequirements)
+	if(pSparseMemoryRequirements)  // Valid to be NULL
 	{
-		UNSUPPORTED("pSparseMemoryRequirements->pNext sType = %s", vk::Stringify(extensionRequirements->sType).c_str());
-		extensionRequirements = extensionRequirements->pNext;
+		const auto *extensionRequirements = reinterpret_cast<const VkBaseInStructure *>(pSparseMemoryRequirements->pNext);
+		while(extensionRequirements)
+		{
+			UNSUPPORTED("pSparseMemoryRequirements->pNext sType = %s", vk::Stringify(extensionRequirements->sType).c_str());
+			extensionRequirements = extensionRequirements->pNext;
+		}
 	}
 
 	// The 'sparseBinding' feature is not supported, so images can not be created with the VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag.