am 51997559: Fail if the new index is out of range. do not merge.

* commit '519975591eba13ae7ac4e494a0dfb88a34ca191b':
  Fail if the new index is out of range. do not merge.
diff --git a/dx/src/com/android/dx/merge/DexMerger.java b/dx/src/com/android/dx/merge/DexMerger.java
index fc4d145..b7677cf 100644
--- a/dx/src/com/android/dx/merge/DexMerger.java
+++ b/dx/src/com/android/dx/merge/DexMerger.java
@@ -406,6 +406,9 @@
             }
 
             @Override void updateIndex(int offset, IndexMap indexMap, int oldIndex, int newIndex) {
+                if (newIndex < 0 || newIndex > 0xffff) {
+                    throw new IllegalArgumentException("type ID not in [0, 0xffff]: " + newIndex);
+                }
                 indexMap.typeIds[oldIndex] = (short) newIndex;
             }
 
@@ -446,6 +449,9 @@
             }
 
             @Override void updateIndex(int offset, IndexMap indexMap, int oldIndex, int newIndex) {
+                if (newIndex < 0 || newIndex > 0xffff) {
+                    throw new IllegalArgumentException("proto ID not in [0, 0xffff]: " + newIndex);
+                }
                 indexMap.protoIds[oldIndex] = (short) newIndex;
             }
 
@@ -466,6 +472,9 @@
             }
 
             @Override void updateIndex(int offset, IndexMap indexMap, int oldIndex, int newIndex) {
+                if (newIndex < 0 || newIndex > 0xffff) {
+                    throw new IllegalArgumentException("field ID not in [0, 0xffff]: " + newIndex);
+                }
                 indexMap.fieldIds[oldIndex] = (short) newIndex;
             }
 
@@ -486,6 +495,9 @@
             }
 
             @Override void updateIndex(int offset, IndexMap indexMap, int oldIndex, int newIndex) {
+                if (newIndex < 0 || newIndex > 0xffff) {
+                    throw new IllegalArgumentException("method ID not in [0, 0xffff]: " + newIndex);
+                }
                 indexMap.methodIds[oldIndex] = (short) newIndex;
             }