JAL-2046 explicitly copy char[] when cloning sequence data for copy-constructor/deriv...
authorJim Procter <jprocter@issues.jalview.org>
Tue, 5 Apr 2016 17:14:42 +0000 (18:14 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 5 Apr 2016 17:45:17 +0000 (18:45 +0100)
src/jalview/datamodel/Sequence.java

index 6f1b403..cb3ae70 100755 (executable)
@@ -25,6 +25,7 @@ import jalview.api.DBRefEntryI;
 import jalview.util.StringUtils;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.List;
 import java.util.Vector;
@@ -216,8 +217,12 @@ public class Sequence extends ASequence implements SequenceI
   protected void initSeqFrom(SequenceI seq,
           AlignmentAnnotation[] alAnnotation)
   {
-    initSeqAndName(seq.getName(), seq.getSequence(), seq.getStart(),
+    {
+      char[] oseq = seq.getSequence();
+      initSeqAndName(seq.getName(), Arrays.copyOf(oseq, oseq.length),
+              seq.getStart(),
             seq.getEnd());
+    }
     description = seq.getDescription();
     sourceDBRef = seq.getSourceDBRef() == null ? null : new DBRefEntry(
             seq.getSourceDBRef());