From 476318fd7667f4af97615e895643840eed40ecd5 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Mon, 3 Jun 2013 12:01:42 -0400 Subject: [PATCH] adding AIOOBE to removeIndex() in Dict classes --- core/src/processing/data/FloatDict.java | 3 +++ core/src/processing/data/IntDict.java | 3 +++ core/src/processing/data/StringDict.java | 3 +++ 3 files changed, 9 insertions(+) diff --git a/core/src/processing/data/FloatDict.java b/core/src/processing/data/FloatDict.java index 0e6873732..58d006149 100644 --- a/core/src/processing/data/FloatDict.java +++ b/core/src/processing/data/FloatDict.java @@ -491,6 +491,9 @@ public class FloatDict { public String removeIndex(int index) { + if (index < 0 || index >= count) { + throw new ArrayIndexOutOfBoundsException(index); + } String key = keys[index]; //System.out.println("index is " + which + " and " + keys[which]); indices.remove(keys[index]); diff --git a/core/src/processing/data/IntDict.java b/core/src/processing/data/IntDict.java index 971dc6e1e..ed22a27f7 100644 --- a/core/src/processing/data/IntDict.java +++ b/core/src/processing/data/IntDict.java @@ -502,6 +502,9 @@ public class IntDict { public String removeIndex(int index) { + if (index < 0 || index >= count) { + throw new ArrayIndexOutOfBoundsException(index); + } //System.out.println("index is " + which + " and " + keys[which]); String key = keys[index]; indices.remove(keys[index]); diff --git a/core/src/processing/data/StringDict.java b/core/src/processing/data/StringDict.java index bc3124835..afc7ea49a 100644 --- a/core/src/processing/data/StringDict.java +++ b/core/src/processing/data/StringDict.java @@ -292,6 +292,9 @@ public class StringDict { public String removeIndex(int index) { + if (index < 0 || index >= count) { + throw new ArrayIndexOutOfBoundsException(index); + } //System.out.println("index is " + which + " and " + keys[which]); String key = keys[index]; indices.remove(key);