1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixes an ArrayOutOfBoundsException, bug 190884.

This commit is contained in:
Markus Schorn 2008-05-30 11:48:48 +00:00
parent 7e1f9c87fc
commit 048ddb3469
2 changed files with 18 additions and 2 deletions

View file

@ -121,4 +121,14 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateEOF();
validateProblemCount(0);
}
// "unintentionally unbounded
// "
//
public void testUnboundedEmptyStringLiteral_Bug190884() throws Exception {
initializeScanner();
validateString("unintentionally unbounded");
validateEOF();
validateProblemCount(2);
}
}

View file

@ -532,8 +532,14 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
private void appendStringContent(StringBuffer buf, Token t1) {
final char[] image= t1.getCharImage();
final int length= image.length;
if (length > 1) {
final int start= image[0]=='"' ? 1 : 2;
buf.append(image, start, image.length-start-1);
final int diff= image[length-1] == '"' ? length-start-1 : length-start;
if (diff > 0) {
buf.append(image, start, diff);
}
}
}
Token internalFetchToken(final boolean expandMacros, final boolean isPPCondition, final boolean stopAtNewline,