513c341de48cb678f5cead976cfccb664072316f
braney
  Wed Sep 10 16:35:44 2014 -0700
fix crash in output of predicted mRNA from geneid track #13861
diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index b4215ca..55c77a0 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -8221,36 +8221,37 @@
  * an alignment of an mRNA to the genome.  Going to have to come back
  * and address that later... (acs) */
 
 dnaTranslateSome(cdsDna->dna+offset, prot, protBufSize);
 dnaSeqFree(&cdsDna);
 return prot;
 }
 
 
 
 void htcGeneMrna(char *geneName)
 /* Display cDNA predicted from genome */
 {
 char *table = cartString(cart, "o");
 cartHtmlStart("Predicted mRNA from Genome");
-struct genePred *gp, *gpList = getGenePredForPosition(table, geneName);
+struct genePred *gp, *gpList = getGenePredForPosition(table, geneName), *next;
 int cdsStart, cdsEnd;
 struct dnaSeq *seq;
 
-for(gp = gpList; gp; gp = gp->next)
+for(gp = gpList; gp; gp = next)
     {
+    next = gp->next;
     seq = getCdnaSeq(gp);
     getCdsInMrna(gp, &cdsStart, &cdsEnd);
     toUpperN(seq->dna + cdsStart, cdsEnd - cdsStart);
     if (gp->strand[0] == '-')
 	{
         reverseComplement(seq->dna, seq->size);
 	}
     printf("<PRE><TT>");
     printf(">%s\n", geneName);
     faWriteNext(stdout, NULL, seq->dna, seq->size);
     printf("</TT></PRE>");
     genePredFree(&gp);
     freeDnaSeq(&seq);
     }
 }