From d0d9ec8b09e6e536f13d552eeac759043dcc3b88 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 4 Oct 2009 06:05:22 +0000 Subject: [PATCH] Allow input array of zero length. --- .../parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java index 91521de243a..289f3aaa19a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/ArrayUtil.java @@ -43,7 +43,7 @@ public abstract class ArrayUtil { return array; } - Object[] temp = (Object[]) Array.newInstance(c, array.length * 2); + Object[] temp = (Object[]) Array.newInstance(c, Math.max(array.length * 2, DEFAULT_LENGTH)); System.arraycopy(array, 0, temp, 0, array.length); temp[array.length] = obj; return temp; @@ -119,7 +119,8 @@ public abstract class ArrayUtil { return array; } - T[] temp = (T[]) Array.newInstance(array.getClass().getComponentType(), array.length * 2); + T[] temp = (T[]) Array.newInstance(array.getClass().getComponentType(), + Math.max(array.length * 2, DEFAULT_LENGTH)); System.arraycopy(array, 0, temp, 0, array.length); temp[array.length] = obj; return temp;