From a3726ec79fa99a18a8dcad3163f0156382031238 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 3 Apr 2008 06:41:37 -0400 Subject: [PATCH] Another string literal via non-const char pointer fix. --HG-- branch : trunk --- mojoshader.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index 523bae8b..b922999b 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -731,10 +731,13 @@ static char *make_D3D_destarg_string(Context *ctx, const int idx) static char *make_D3D_sourcearg_string(Context *ctx, const int idx) { + char *retval = get_scratch_buffer(ctx); + *retval = '\0'; // truncate string to start. + if (idx >= STATICARRAYLEN(ctx->source_args)) { fail(ctx, "Too many source args"); - return ""; + return retval; } // if const SourceArgInfo *arg = &ctx->source_args[idx]; @@ -805,7 +808,7 @@ static char *make_D3D_sourcearg_string(Context *ctx, const int idx) if (regtype_str == NULL) { fail(ctx, "Unknown source register type."); - return ""; + return retval; } // if char swizzle_str[6]; @@ -826,7 +829,6 @@ static char *make_D3D_sourcearg_string(Context *ctx, const int idx) swizzle_str[i] = '\0'; assert(i < sizeof (swizzle_str)); - char *retval = get_scratch_buffer(ctx); snprintf(retval, SCRATCH_BUFFER_SIZE, "%s%s%s%s%s", premod_str, regtype_str, regnum_str, postmod_str, swizzle_str); return retval;