summaryrefslogtreecommitdiffstats
path: root/source/slang/slang.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-09-08 14:48:05 -0400
committerGitHub <noreply@github.com>2020-09-08 14:48:05 -0400
commit3a34db6e8864df51b9ae93fe46c6d98c4cfc77bb (patch)
tree1e6c98f470e1300cb17f55e2cc1e9ff26fb87e9b /source/slang/slang.cpp
parent8740252f04c4fe96c5d19a8f07cac43037087e15 (diff)
Test if blob is returned. (#1535)
Diffstat (limited to 'source/slang/slang.cpp')
-rw-r--r--source/slang/slang.cpp20
1 files changed, 10 insertions, 10 deletions
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<ISlangBlob> 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(