changeset 5890:285765be3123

8000638: Improve deserialization Reviewed-by: smarks, hawtin, mchung
author dmocek
date Mon, 04 Mar 2013 14:34:15 -0800
parents a46991f99fc3
children be15531f9b71
files src/share/classes/java/io/ObjectStreamClass.java
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/io/ObjectStreamClass.java	Mon Mar 04 12:29:30 2013 -0800
+++ b/src/share/classes/java/io/ObjectStreamClass.java	Mon Mar 04 14:34:15 2013 -0800
@@ -1151,7 +1151,14 @@
             end = end.getSuperclass();
         }
 
+        HashSet<String> oscNames = new HashSet<>(3);
+
         for (ObjectStreamClass d = this; d != null; d = d.superDesc) {
+            if (oscNames.contains(d.name)) {
+                throw new InvalidClassException("Circular reference.");
+            } else {
+                oscNames.add(d.name);
+            }
 
             // search up inheritance hierarchy for class with matching name
             String searchName = (d.cl != null) ? d.cl.getName() : d.name;