Skip to content

Commit

Permalink
Don't keep processing bytecode if the data is clearly not a shader at…
Browse files Browse the repository at this point in the history
… all.
  • Loading branch information
icculus committed Mar 24, 2010
1 parent 1445250 commit e8a8e69
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mojoshader.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit e8a8e69

Please sign in to comment.