You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"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++;
}
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
The text was updated successfully, but these errors were encountered: