From e8a8e69a5b442c2cd9205140ce4e3f6b516a999f Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 24 Mar 2010 09:56:34 -0400 Subject: [PATCH] Don't keep processing bytecode if the data is clearly not a shader at all. --- mojoshader.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mojoshader.c b/mojoshader.c index fdc485b1..f7408ce0 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -6709,6 +6709,7 @@ static int parse_version_token(Context *ctx, const char *profilestr) 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 @@ const MOJOSHADER_parseData *MOJOSHADER_parse(const char *profile, 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");