[vlc-commits] 3d11_shaders: use asprintf() instead of malloc()+sprintf()
Steve Lhomme
git at videolan.org
Fri Oct 19 15:43:31 CEST 2018
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Oct 19 15:29:04 2018 +0200| [f32347a9a5957455e7854368c9cadef8323d500c] | committer: Steve Lhomme
3d11_shaders: use asprintf() instead of malloc()+sprintf()
This will avoid some copy+paste mistakes
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f32347a9a5957455e7854368c9cadef8323d500c
---
modules/video_output/win32/d3d11_shaders.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/modules/video_output/win32/d3d11_shaders.c b/modules/video_output/win32/d3d11_shaders.c
index f023de481f..29a1e35738 100644
--- a/modules/video_output/win32/d3d11_shaders.c
+++ b/modules/video_output/win32/d3d11_shaders.c
@@ -216,17 +216,16 @@ static HRESULT CompileTargetShader(vlc_object_t *o, d3d11_handle_t *hd3d, bool l
const char *psz_adjust_range, const char *psz_move_planes,
ID3D11PixelShader **output)
{
- char *shader = malloc(strlen(globPixelShaderDefault) + 32 + strlen(psz_sampler) +
- strlen(psz_src_transform) + strlen(psz_primaries_transform) + strlen(psz_display_transform) +
- strlen(psz_tone_mapping) + strlen(psz_adjust_range) + strlen(psz_move_planes));
- if (!shader)
+ char *shader;
+ int allocated = asprintf(&shader, globPixelShaderDefault, legacy_shader ? "" : "Array",
+ psz_src_transform, psz_display_transform,
+ psz_primaries_transform, psz_tone_mapping,
+ psz_adjust_range, psz_move_planes, psz_sampler);
+ if (allocated <= 0)
{
msg_Err(o, "no room for the Pixel Shader");
return E_OUTOFMEMORY;
}
- sprintf(shader, globPixelShaderDefault, legacy_shader ? "" : "Array", psz_src_transform,
- psz_display_transform, psz_primaries_transform, psz_tone_mapping,
- psz_adjust_range, psz_move_planes, psz_sampler);
if (var_InheritInteger(o, "verbose") >= 4)
msg_Dbg(o, "shader %s", shader);
#ifndef NDEBUG
More information about the vlc-commits
mailing list