}
// We need at least maxFromSize so we can iterate and replace
- source = new byte[Math.max(2 * maxFromSize, MIN_BUFFER_SIZE)];
+ source = new byte[Math.max(2 * Math.max(maxToSize, maxFromSize),
+ MIN_BUFFER_SIZE)];
spos = 0;
slen = 0;
}
if (froms[i] != null && froms[i].length > 0
&& StreamUtils.startsWith(froms[i], source, spos, slen)) {
if (tos[i] != null && tos[i].length > 0) {
- System.arraycopy(tos[i], 0, buffer, off + spos,
+ System.arraycopy(tos[i], 0, buffer, off + count,
tos[i].length);
count += tos[i].length;
}
-
+
spos += froms[i].length;
replaced = true;
break;