diff --git a/JSONArray.java b/JSONArray.java index 673a91927..3931dbf64 100644 --- a/JSONArray.java +++ b/JSONArray.java @@ -813,9 +813,8 @@ public JSONArray put(int index, Object value) throws JSONException { * was no value. */ public Object remove(int index) { - Object o = this.opt(index); - this.myArrayList.remove(index); - return o; + return (index < 0 || index >= this.length()) ? null : this.myArrayList + .remove(index); } /**