From 30ac55d0673047eef5f34432bed2ad458c735d42 Mon Sep 17 00:00:00 2001 From: Axel Petzold Date: Wed, 19 Aug 2015 12:37:49 +0200 Subject: [PATCH] handling of references to arrays fixed --- jdeserialize/src/jdeserialize.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jdeserialize/src/jdeserialize.java b/jdeserialize/src/jdeserialize.java index 51d2a93..3e929ca 100644 --- a/jdeserialize/src/jdeserialize.java +++ b/jdeserialize/src/jdeserialize.java @@ -224,13 +224,13 @@ public Object read_FieldValue(fieldtype f, DataInputStream dis) throws IOExcepti case OBJECT: case ARRAY: byte stc = dis.readByte(); - if(f == fieldtype.ARRAY && stc != ObjectStreamConstants.TC_ARRAY) { - throw new IOException("array type listed, but typecode is not TC_ARRAY: " + hex(stc)); - } content c = read_Content(stc, dis, false); if(c != null && c.isExceptionObject()) { throw new ExceptionReadException(c); } + if(f == fieldtype.ARRAY && !(c instanceof arrayobj)) { + throw new IOException("expected an array, but got something else!"); + } return c; default: throw new IOException("can't process type: " + f.toString()); @@ -627,7 +627,9 @@ public arrayobj read_newArray(DataInputStream dis) throws IOException { throw new IOException("invalid name in array classdesc: " + cd.name); } arraycoll ac = read_arrayValues(cd.name.substring(1), dis); - return new arrayobj(handle, cd, ac); + arrayobj ao = new arrayobj(handle, cd, ac); + setHandle(handle, ao); + return ao; } public arraycoll read_arrayValues(String str, DataInputStream dis) throws IOException { byte b = str.getBytes("UTF-8")[0];