diff --git a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp index 88fe7f46e..46d1e7c9b 100644 --- a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp +++ b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp @@ -32,7 +32,7 @@ std::unique_ptr IntermediateShader::make_shader(const std::s const char *input_variable = input_is_inputPosition ? "inputPosition" : "outputPosition"; char *vertex_shader; - (void)asprintf(&vertex_shader, + int length = asprintf(&vertex_shader, "#version 150\n" "in vec2 inputStart;" @@ -107,6 +107,8 @@ std::unique_ptr IntermediateShader::make_shader(const std::s "gl_Position = vec4(eyePosition, 0.0, 1.0);" "}", sampler_type, input_variable); + if(length <= 0) return nullptr; + std::unique_ptr shader(new IntermediateShader(vertex_shader, fragment_shader, bindings)); std::free(vertex_shader); @@ -117,7 +119,7 @@ std::unique_ptr IntermediateShader::make_source_conversion_s char *derived_composite_sample = nullptr; const char *composite_sample = composite_shader.c_str(); if(!composite_shader.size()) { - (void)asprintf(&derived_composite_sample, + int length = asprintf(&derived_composite_sample, "%s\n" "uniform mat3 rgbToLumaChroma;" "float composite_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase, float amplitude)" @@ -128,11 +130,14 @@ std::unique_ptr IntermediateShader::make_source_conversion_s "return dot(lumaChromaColour, vec3(1.0 - amplitude, quadrature));" "}", rgb_shader.c_str()); + if(length <= 0) { + derived_composite_sample = nullptr; + } composite_sample = derived_composite_sample; } char *fragment_shader; - (void)asprintf(&fragment_shader, + int length = asprintf(&fragment_shader, "#version 150\n" "in vec2 inputPositionsVarying[11];" @@ -152,6 +157,8 @@ std::unique_ptr IntermediateShader::make_source_conversion_s , composite_sample); std::free(derived_composite_sample); + if(!length) return nullptr; + std::unique_ptr shader = make_shader(fragment_shader, true, true); std::free(fragment_shader); @@ -160,7 +167,7 @@ std::unique_ptr IntermediateShader::make_source_conversion_s std::unique_ptr IntermediateShader::make_rgb_source_shader(const std::string &rgb_shader) { char *fragment_shader; - (void)asprintf(&fragment_shader, + int length = asprintf(&fragment_shader, "#version 150\n" "in vec2 inputPositionsVarying[11];" @@ -179,6 +186,8 @@ std::unique_ptr IntermediateShader::make_rgb_source_shader(c "}" , rgb_shader.c_str()); + if(length <= 0) return nullptr; + std::unique_ptr shader = make_shader(fragment_shader, true, true); std::free(fragment_shader); diff --git a/Outputs/CRT/Internals/Shaders/OutputShader.cpp b/Outputs/CRT/Internals/Shaders/OutputShader.cpp index 956fea938..095847329 100644 --- a/Outputs/CRT/Internals/Shaders/OutputShader.cpp +++ b/Outputs/CRT/Internals/Shaders/OutputShader.cpp @@ -25,7 +25,7 @@ std::unique_ptr OutputShader::make_shader(const char *fragment_met const char *sampler_type = use_usampler ? "usampler2D" : "sampler2D"; char *vertex_shader; - (void)asprintf(&vertex_shader, + int vertex_length = asprintf(&vertex_shader, "#version 150\n" "in vec2 horizontal;" @@ -64,7 +64,7 @@ std::unique_ptr OutputShader::make_shader(const char *fragment_met "}", sampler_type); char *fragment_shader; - (void)asprintf(&fragment_shader, + int fragment_length = asprintf(&fragment_shader, "#version 150\n" "in float lateralVarying;" @@ -84,6 +84,8 @@ std::unique_ptr OutputShader::make_shader(const char *fragment_met "}", sampler_type, fragment_methods, colour_expression); + if(vertex_length <= 0 || fragment_length <= 0) return nullptr; + std::unique_ptr result(new OutputShader(vertex_shader, fragment_shader, bindings)); std::free(vertex_shader); std::free(fragment_shader);