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:
parent
7e1f9c87fc
commit
048ddb3469
2 changed files with 18 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 start= image[0]=='"' ? 1 : 2;
|
||||
buf.append(image, start, image.length-start-1);
|
||||
final int length= image.length;
|
||||
if (length > 1) {
|
||||
final int start= image[0]=='"' ? 1 : 2;
|
||||
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,
|
||||
|
|
Loading…
Add table
Reference in a new issue