diff options
author | Ito Kazumitsu <kaz@maczuka.gcd.org> | 2004-02-15 11:53:45 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2004-02-15 11:53:45 +0000 |
commit | af1967542f8f4607594bc6494014a8b01bd94b9f (patch) | |
tree | c660e6ecd4e14c53bd2fac8a47a6a82302bd1dbe /libjava/java | |
parent | fa7c0d68a454415105defac67eca983f425a17b0 (diff) | |
download | gcc-af1967542f8f4607594bc6494014a8b01bd94b9f.zip gcc-af1967542f8f4607594bc6494014a8b01bd94b9f.tar.gz gcc-af1967542f8f4607594bc6494014a8b01bd94b9f.tar.bz2 |
ObjectInputStream.java (readClassDescriptor): Avoid the overflow of fieldmapping.
2004-02-15 Ito Kazumitsu <kaz@maczuka.gcd.org>
* java/io/ObjectInputStream.java (readClassDescriptor): Avoid the
overflow of fieldmapping.
From-SVN: r77843
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/io/ObjectInputStream.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/libjava/java/io/ObjectInputStream.java b/libjava/java/io/ObjectInputStream.java index e471b6d..ce2d0ca 100644 --- a/libjava/java/io/ObjectInputStream.java +++ b/libjava/java/io/ObjectInputStream.java @@ -1,5 +1,6 @@ /* ObjectInputStream.java -- Class used to read serialized objects - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 + Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -491,7 +492,6 @@ public class ObjectInputStream extends InputStream ObjectStreamField[] stream_fields = osc.fields; ObjectStreamField[] real_fields = ObjectStreamClass.lookup(clazz).fields; ObjectStreamField[] fieldmapping = new ObjectStreamField[2 * Math.max(stream_fields.length, real_fields.length)]; - osc.fieldMapping = fieldmapping; int stream_idx = 0; int real_idx = 0; @@ -543,9 +543,21 @@ public class ObjectInputStream extends InputStream } if (real_field != null && !real_field.isToSet()) real_field = null; + /* If some of stream_fields does not correspond to any of real_fields, + * or the opposite, then fieldmapping will go short. + */ + if (map_idx == fieldmapping.length) + { + ObjectStreamField[] newfieldmapping = + new ObjectStreamField[fieldmapping.length + 2]; + System.arraycopy(fieldmapping, 0, + newfieldmapping, 0, fieldmapping.length); + fieldmapping = newfieldmapping; + } fieldmapping[map_idx++] = stream_field; fieldmapping[map_idx++] = real_field; } + osc.fieldMapping = fieldmapping; return osc; } |