Skip to content

Commit 4995c3d

Browse files
committed
Fixed exception with empty byte arrays
1 parent 2296eee commit 4995c3d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/de/rub/nds/modifiablevariable/bytearray/ByteArrayExplicitValueModification.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
1919

2020
@XmlRootElement
21-
@XmlType(propOrder = { "explicitValue", "modificationFilter", "postModification" })
21+
@XmlType(propOrder = {"explicitValue", "modificationFilter", "postModification"})
2222
public class ByteArrayExplicitValueModification extends VariableModification<byte[]> {
2323

2424
private byte[] explicitValue;
@@ -54,6 +54,9 @@ public String toString() {
5454
@Override
5555
public VariableModification<byte[]> getModifiedCopy() {
5656
Random r = new Random();
57+
if (explicitValue.length == 0) {
58+
return this;
59+
}
5760
int index = r.nextInt(explicitValue.length);
5861
byte[] newValue = Arrays.copyOf(explicitValue, explicitValue.length);
5962
newValue[index] = (byte) r.nextInt(256);

0 commit comments

Comments
 (0)