[
https://issues.apache.org/jira/browse/XMLBEANS-474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
PJ Fanning resolved XMLBEANS-474.
---------------------------------
Resolution: Fixed
> NegativeArraySizeException thrown from TextSaver.resize
> -------------------------------------------------------
>
> Key: XMLBEANS-474
> URL: https://issues.apache.org/jira/browse/XMLBEANS-474
> Project: XMLBeans
> Issue Type: Bug
> Affects Versions: Version 2.5
> Reporter: Dan Faershtein
> Priority: Major
> Fix For: Version 5.2.0
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> TextSever.resize()
> does not check if "newLen" is negative which can happen if requested size is
> more than ( Integer.MAX_VALUE / 2)
> consider core java implementation AbstractStringBuilder:expandCapacity:
> void expandCapacity(int minimumCapacity) {
> int newCapacity = (value.length + 1) * 2;
> if (newCapacity < 0) {
> newCapacity = Integer.MAX_VALUE;
> } else if (minimumCapacity > newCapacity) {
> newCapacity = minimumCapacity;
> }
> value = Arrays.copyOf(value, newCapacity);
> }
> Here is the exception stack trace:
> Nov 18 16:09:31 localhost java.lang.NegativeArraySizeException
> Nov 18 16:09:31 localhost at
> org.apache.xmlbeans.impl.store.Saver$TextSaver.resize(Saver.java:1695)
> Nov 18 16:09:31 localhost at
> org.apache.xmlbeans.impl.store.Saver$TextSaver.preEmit(Saver.java:1300)
> Nov 18 16:09:31 localhost at
> org.apache.xmlbeans.impl.store.Saver$TextSaver.emit(Saver.java:1231)
> Nov 18 16:09:31 localhost at
> org.apache.xmlbeans.impl.store.Saver$TextSaver.emitAttrHelper(Saver.java:1027)
> Nov 18 16:09:31 localhost at
> org.apache.xmlbeans.impl.store.Saver$TextSaver.emitElement(Saver.java:966)
> Nov 18 16:09:31 localhost at
> org.apache.xmlbeans.impl.store.Saver.processElement(Saver.java:476)
> Nov 18 16:09:31 localhost at
> org.apache.xmlbeans.impl.store.Saver.process(Saver.java:307)
> Nov 18 16:09:31 localhost at
> org.apache.xmlbeans.impl.store.Saver$TextSaver.saveToString(Saver.java:1859)
> Nov 18 16:09:31 localhost at
> org.apache.xmlbeans.impl.store.Cursor._xmlText(Cursor.java:546)
> Nov 18 16:09:31 localhost at
> org.apache.xmlbeans.impl.store.Cursor.xmlText(Cursor.java:2436)
> Nov 18 16:09:31 localhost at
> org.apache.xmlbeans.impl.values.XmlObjectBase.xmlText(XmlObjectBase.java:1489)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]