Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in the RemoveComments function of FbScript class [DNET370] #375

Closed
firebird-automations opened this issue Mar 15, 2011 · 1 comment
Closed

Comments

@firebird-automations
Copy link

Submitted by: Naveen Rajamohan (naveen)

Execute the below query without the double quotes

"select * from table_name
--This is a comment line"

The above query will result in an "IndexOutOfRange" exception. I debugged the source code and found that the problem is because, in the RemoveComments() function, there is code as follows

else if ((source[i] == '-' && (i < length - 1) && source[i + 1] == '-'))
{
i++;
while (source[i] != '\n')// exeception will occur at this line
{
i++;
}
i--;
}

the while codition is only checking for '\n', but in the above query since the comment is in the last line, it will never find another '\n', so the loop index will grow to a value greater than the length of string causing the above exception

The while loop should actually be modified as follows
while( i < length && source[i] != '\n' )
{
i++;
}

Commits: 35eaee3

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.6.1 [ 10400 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants