Commit 390a3ba5 authored by ebruneton's avatar ebruneton
Browse files

fixed "bug" #315882

parent 54db4288
......@@ -714,6 +714,9 @@ public class ClassWriter implements ClassVisitor {
* @return the bytecode of the class that was build with this class writer.
*/
public byte[] toByteArray() {
if (index > Short.MAX_VALUE) {
throw new RuntimeException("Class file too large!");
}
// computes the real size of the bytecode of this class
int size = 24 + 2 * interfaceCount;
int nbFields = 0;
......@@ -1110,8 +1113,8 @@ public class ClassWriter implements ClassVisitor {
if (result == null) {
pool.putByte(LONG).putLong(value);
result = new Item(index, key);
put(result);
index += 2;
put(result);
}
return result;
}
......@@ -1129,8 +1132,8 @@ public class ClassWriter implements ClassVisitor {
if (result == null) {
pool.putByte(DOUBLE).putLong(key.longVal);
result = new Item(index, key);
put(result);
index += 2;
put(result);
}
return result;
}
......@@ -1334,7 +1337,7 @@ public class ClassWriter implements ClassVisitor {
* @param i the item to be added to the constant pool's hash table.
*/
private void put(final Item i) {
if (index > threshold) {
if (index + typeCount > threshold) {
int ll = items.length;
int nl = ll * 2 + 1;
Item[] newItems = new Item[nl];
......
......@@ -1784,6 +1784,9 @@ class MethodWriter implements MethodVisitor {
}
int size = 8;
if (code.length > 0) {
if (code.length > 65536) {
throw new RuntimeException("Method code too large!");
}
cw.newUTF8("Code");
size += 18 + code.length + 8 * handlerCount;
if (localVar != null) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment