Don't keep processing bytecode if the data is clearly not a shader at all.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 24 Mar 2010 09:56:34 -0400
changeset 900 9673cb4bd0e8
parent 899 460820bb1286
child 901 a9f799b93150
Don't keep processing bytecode if the data is clearly not a shader at all.
mojoshader.c
--- a/mojoshader.c	Fri Mar 12 19:51:04 2010 -0500
+++ b/mojoshader.c	Wed Mar 24 09:56:34 2010 -0400
@@ -6709,6 +6709,7 @@
     else  // geometry shader? Bogus data?
     {
         fail(ctx, "Unsupported shader type or not a shader at all");
+        return -1;
     } // else
 
     ctx->major_ver = major;
@@ -7676,6 +7677,15 @@
     ctx->parse_phase = MOJOSHADER_PARSEPHASE_WORKING;
     rc = parse_version_token(ctx, profile);
 
+    // drop out now if this definitely isn't bytecode. Saves lots of
+    //  meaningless errors flooding through.
+    if (rc < 0)
+    {
+        retval = build_parsedata(ctx);
+        destroy_context(ctx);
+        return retval;
+    } // if
+
     if ( ((uint32) rc) > ctx->tokencount )
     {
         fail(ctx, "Corrupted or truncated shader");