From 3a34db6e8864df51b9ae93fe46c6d98c4cfc77bb Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 8 Sep 2020 14:48:05 -0400 Subject: Test if blob is returned. (#1535) --- source/slang/slang.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index b9381eec3..c97da7125 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -3390,6 +3390,13 @@ SLANG_API void const* spGetEntryPointCode( size_t* outSize) { using namespace Slang; + + // Zero the size initially, in case need to return nullptr for error. + if (outSize) + { + *outSize = 0; + } + auto req = Slang::asInternal(request); auto linkage = req->getLinkage(); auto program = req->getSpecializedGlobalAndEntryPointsComponentType(); @@ -3411,22 +3418,15 @@ SLANG_API void const* spGetEntryPointCode( return nullptr; CompileResult& result = targetProgram->getExistingEntryPointResult(entryPointIndex); - void const* data = nullptr; - size_t size = 0; - ComPtr blob; - if (SLANG_SUCCEEDED(result.getBlob(blob))) - { - data = blob->getBufferPointer(); - size = blob->getBufferSize(); - } + SLANG_RETURN_NULL_ON_FAIL(result.getBlob(blob)); if (outSize) { - *outSize = size; + *outSize = blob->getBufferSize(); } - return data; + return (void*)blob->getBufferPointer(); } static SlangResult _getEntryPointResult( -- cgit v1.2.3