Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-7983: Utils.toUTF8 uses shorter buffer than necessary for holding UTF8 data

Shalin Shekhar Mangarf8eaccd19fd6
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
index e28c717f60c..8e656ba6606 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/Utils.java
@@ -84,7 +84,7 @@ public class Utils {
}
public static byte[] toUTF8(CharArr out) {
- byte[] arr = new byte[out.size() << 2]; // is 4x the real worst-case upper-bound?
+ byte[] arr = new byte[out.size() * 3];
int nBytes = ByteUtils.UTF16toUTF8(out, 0, out.size(), arr, 0);
return Arrays.copyOf(arr, nBytes);
}