You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Guard against overflow of String Builder Transformer estimate
String Builder Transformer uses the result of getStringUTF8Length
to estimate the StringBuilder buffer size needed to accommodate
appending a constant String to a StringBuilder. That could
overestimate the space required. This has been changed to use
getStringLength instead, to use the actual lengths of constant String
objects. A test has also been added to detect integer overflow of the
capacity estimate, aborting the transformation, as StringBuilder.<init>
will throw a NegativeArraySizeException if the specified capacity is
negative.
Signed-off-by: Henry Zongaro <zongaro@ca.ibm.com>
// Guard against the possibility that the computed capacity has overflowed,
146
+
// as StringBuilder.<init>(I) will throw a NegativeArraySizeException if the
147
+
// capacity argument is negative. It is extremely unlikely that the capacity
148
+
// calculation will overflow, but possible.
149
+
if (capacity < 0)
150
+
{
151
+
return1;
152
+
}
153
+
145
154
if (performTransformation(comp(), "%sTransforming java/lang/StringBuilder.<init>()V call at node [0x%p] to java/lang/StringBuilder.<init>(I)V with capacity = %d\n", OPT_DETAILS, initNode, capacity))
0 commit comments