Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 21961 Details for
Bug 97190
Incorrect handling of large long values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
patch_97190.txt (text/plain), 4.25 KB, created by
Olivier Thomann
on 2005-05-30 10:26:27 EDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2005-05-30 10:26:27 EDT
Size:
4.25 KB
patch
obsolete
>Index: compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java,v >retrieving revision 1.14 >diff -u -r1.14 LongLiteral.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java 23 Feb 2005 02:47:28 -0000 1.14 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/LongLiteral.java 30 May 2005 14:26:08 -0000 >@@ -30,50 +30,71 @@ > public void computeConstant() { > //the overflow (when radix=10) is tested using the fact that > //the value should always grow during its computation >- > int length = source.length - 1; //minus one because the last char is 'l' or 'L' > > long computedValue ; >- if (source[0] == '0') >- { if (length == 1) { constant = Constant.fromValue(0L); return; } >+ if (source[0] == '0') { >+ if (length == 1) { >+ constant = Constant.fromValue(0L); >+ return; >+ } > final int shift,radix; > int j ; >- if ( (source[1] == 'x') || (source[1] == 'X') ) >- { shift = 4 ; j = 2; radix = 16;} >- else >- { shift = 3 ; j = 1; radix = 8;} >+ if ( (source[1] == 'x') || (source[1] == 'X') ) { >+ shift = 4 ; j = 2; radix = 16; >+ } else { >+ shift = 3 ; j = 1; radix = 8; >+ } > int nbDigit = 0; >- while (source[j]=='0') >- { j++; //jump over redondant zero >- if ( j == length) >- { //watch for 0000000000000L >+ while (source[j]=='0') { >+ j++; //jump over redondant zero >+ if ( j == length) { >+ //watch for 0000000000000L > constant = Constant.fromValue(value = 0L); >- return ;}} >+ return ; >+ } >+ } > > int digitValue ; >- if ((digitValue = Character.digit(source[j++],radix)) < 0 ) >- { constant = FORMAT_ERROR; return ;} >- if (digitValue >= 8) nbDigit = 4; >- else if (digitValue >= 4) nbDigit = 3; >- else if (digitValue >= 2) nbDigit = 2; >- else nbDigit = 1; //digitValue is not 0 >+ if ((digitValue = Character.digit(source[j++],radix)) < 0 ) { >+ constant = FORMAT_ERROR; return ; >+ } >+ if (digitValue >= 8) >+ nbDigit = 4; >+ else if (digitValue >= 4) >+ nbDigit = 3; >+ else if (digitValue >= 2) >+ nbDigit = 2; >+ else >+ nbDigit = 1; //digitValue is not 0 > computedValue = digitValue ; >- while (j<length) >- { if ((digitValue = Character.digit(source[j++],radix)) < 0 ) >- { constant = FORMAT_ERROR; return ;} >- if ((nbDigit += shift) > 64) return /*constant stays null*/ ; >- computedValue = (computedValue<<shift) | digitValue ;}} >- >- else >- { //-----------case radix=10----------------- >- long previous = computedValue = 0; >- for (int i = 0 ; i < length; i++) >- { int digitValue ; >- if ((digitValue = Character.digit(source[i], 10)) < 0 ) return /*constant stays null*/ ; >+ while (j<length) { >+ if ((digitValue = Character.digit(source[j++],radix)) < 0) { >+ constant = FORMAT_ERROR; return ; >+ } >+ if ((nbDigit += shift) > 64) >+ return /*constant stays null*/ ; >+ computedValue = (computedValue<<shift) | digitValue ; >+ } >+ } else { >+ //-----------case radix=10----------------- >+ long previous = 0; >+ computedValue = 0; >+ final long limit = Long.MAX_VALUE / 10; // needed to check prior to the multiplication >+ for (int i = 0 ; i < length; i++) { >+ int digitValue ; >+ if ((digitValue = Character.digit(source[i], 10)) < 0 ) return /*constant stays null*/; > previous = computedValue; >- computedValue = 10 * computedValue + digitValue ; >- if (previous > computedValue) return /*constant stays null*/;}} >- >+ if (computedValue > limit) >+ return /*constant stays null*/; >+ computedValue *= 10; >+ if ((computedValue + digitValue) > Long.MAX_VALUE) >+ return /*constant stays null*/; >+ computedValue += digitValue; >+ if (previous > computedValue) >+ return /*constant stays null*/; >+ } >+ } > constant = Constant.fromValue(value = computedValue); > } > /** >@@ -118,7 +139,8 @@ > (source[15] == '5') && > (source[16] == '8') && > (source[17] == '0') && >- (source[18] == '8'));} >+ (source[18] == '8')); >+} > public TypeBinding resolveType(BlockScope scope) { > // the format may be incorrect while the scanner could detect > // such error only on painfull tests...easier and faster here
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 97190
: 21961