Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

asCTokenizer::IsComment


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Jason Goepel   Members   -  Reputation: 443

Like
0Likes
Like

Posted 01 April 2014 - 02:54 PM

The following code checks for a one-line comment.

 

as_tokenizer.cpp(213):

if( source[1] == '/' )
{
    // One-line comment

    // Find the length
    size_t n;
    for( n = 2; n < sourceLength; n++ )
    {
        if( source[n] == '\n' )
            break;
    }

    tokenType   = ttOnelineComment;
    tokenLength = n+1;

    return true;
}

Of the last part of "source" is a comment such that the for loop breaks when n == sourceLength (instead of finding a line feed character), tokenLength gets assigned a value one greater than sourceLength.

 

It seems incorrect that the returned "tokenLength" should exceed the "sourceLength".

 



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3455

Like
0Likes
Like

Posted 01 April 2014 - 04:19 PM

Of course you're right.

 

But how on earth did you find this bug? :)


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 Jason Goepel   Members   -  Reputation: 443

Like
0Likes
Like

Posted 02 April 2014 - 07:21 AM

I had written some preprocessing/intellisense code.  One of my functions "SkipCommentsAndWhitespace" sometimes would crash when the source ended in a single-line comment.  The pointer to the source was increased passed the end of the source (as a result of adding a length returned from the asIScriptEngine::ParseToken function).  I'll admit, it took me a little while to track it down smile.png



#4 Andreas Jonsson   Moderators   -  Reputation: 3455

Like
0Likes
Like

Posted 05 April 2014 - 07:00 PM

Fixed in revision 1890


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS