diff --git a/src/SDL_shadercross.c b/src/SDL_shadercross.c index 04a8ce8..079dcca 100644 --- a/src/SDL_shadercross.c +++ b/src/SDL_shadercross.c @@ -685,9 +685,13 @@ static ID3DBlob *SDL_ShaderCross_INTERNAL_CompileDXBC( &errorBlob); if (ret < 0) { - SDL_SetError( - "HLSL compilation failed: %s", - (char *)errorBlob->lpVtbl->GetBufferPointer(errorBlob)); + if (errorBlob != NULL) { + SDL_SetError( + "HLSL compilation failed: %s", + (char *)errorBlob->lpVtbl->GetBufferPointer(errorBlob)); + } else { + SDL_SetError("HLSL compilation failed for an unknown reason."); + } return NULL; } @@ -1734,6 +1738,10 @@ static void *SDL_ShaderCross_INTERNAL_CompileFromSPIRV( bytecodeSize, entrypoint); + if (transpileContext == NULL) { + return NULL; + } + void *shaderObject = NULL; if (shaderStage == SDL_SHADERCROSS_SHADERSTAGE_COMPUTE) { @@ -1820,6 +1828,10 @@ void *SDL_ShaderCross_TranspileMSLFromSPIRV( entrypoint ); + if (context == NULL) { + return NULL; + } + size_t length = SDL_strlen(context->translated_source) + 1; char *result = SDL_malloc(length); SDL_strlcpy(result, context->translated_source, length); @@ -1843,6 +1855,10 @@ void *SDL_ShaderCross_TranspileHLSLFromSPIRV( entrypoint ); + if (context == NULL) { + return NULL; + } + size_t length = SDL_strlen(context->translated_source) + 1; char *result = SDL_malloc(length); SDL_strlcpy(result, context->translated_source, length); @@ -1866,6 +1882,10 @@ void *SDL_ShaderCross_CompileDXBCFromSPIRV( bytecodeSize, entrypoint); + if (context == NULL) { + return NULL; + } + void *result = SDL_ShaderCross_INTERNAL_CompileDXBCFromHLSL( context->translated_source, context->cleansed_entrypoint, @@ -1898,6 +1918,10 @@ void *SDL_ShaderCross_CompileDXILFromSPIRV( bytecodeSize, entrypoint); + if (context == NULL) { + return NULL; + } + void *result = SDL_ShaderCross_CompileDXILFromHLSL( context->translated_source, context->cleansed_entrypoint,