Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed error line numbers when assembler gets errors from bytecode val…
…idation.
  • Loading branch information
icculus committed Feb 12, 2009
1 parent 23c7159 commit 4018cf4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions mojoshader_assembler.c
Expand Up @@ -1875,6 +1875,8 @@ const MOJOSHADER_parseData *MOJOSHADER_assemble(const char *source,
if (error->error_position >= 0)
{
assert(retval != &MOJOSHADER_out_of_mem_data);
assert((error->error_position % sizeof (uint32)) == 0);

const int pos = error->error_position / sizeof (uint32);
if (pos >= ctx->output_len)
error->error_position = -1; // oh well.
Expand All @@ -1884,11 +1886,8 @@ const MOJOSHADER_parseData *MOJOSHADER_assemble(const char *source,
Free(ctx, (void *) error->filename);
char *fname = NULL;
if (srcpos->filename != NULL)
{
fname = StrDup(ctx, srcpos->filename);
if (fname != NULL)
error->error_position = srcpos->line;
} // if
error->error_position = srcpos->line;
error->filename = fname; // may be NULL, that's okay.
} // else
} // if
Expand Down

0 comments on commit 4018cf4

Please sign in to comment.