Skip to content

Commit cde9a70

Browse files
committed
fix bug, if there is no NL in the last line comment sqlitebrowser#40
if there was no NL in the line comment we ran into an endless recursion, now we check for that corner case.
1 parent 09b4343 commit cde9a70

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/sqlitetablemodel.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ QString removeComments(QString s)
6161
else if(!(!stringChars.empty() && (stringChars.last() != '\'' || stringChars.last() != '"')) || stringChars.empty())
6262
stringChars.push_back(s.at(i));
6363
} else if(stringChars.empty() && s.at(i) == '-' && lastChar == '-') {
64-
if(s.contains('\n'))
65-
return removeComments(s.remove(i-1, s.indexOf('\n', i)-i+2));
64+
int nextNL = s.indexOf('\n', i);
65+
if(nextNL >= 0)
66+
return removeComments(s.remove(i-1, nextNL - i + 2));
6667
else
6768
return s.left(i-1);
6869
}

0 commit comments

Comments
 (0)