Another string literal via non-const char pointer fix. trunk
authorRyan C. Gordon <icculus@icculus.org>
Thu, 03 Apr 2008 06:41:37 -0400
branchtrunk
changeset 66 64c37d56e19f
parent 65 aa0b9bb40df7
child 67 cc42106d11ec
Another string literal via non-const char pointer fix.
mojoshader.c
--- a/mojoshader.c	Thu Apr 03 06:40:22 2008 -0400
+++ b/mojoshader.c	Thu Apr 03 06:41:37 2008 -0400
@@ -731,10 +731,13 @@
 
 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 @@
     if (regtype_str == NULL)
     {
         fail(ctx, "Unknown source register type.");
-        return "";
+        return retval;
     } // if
 
     char swizzle_str[6];
@@ -826,7 +829,6 @@
     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;