ea4e0db808801644e3fa40916bc3b0a7216cebba
max
  Wed Jul 5 14:50:26 2017 -0700
fixing a bug in the crisprTrack due to stupid memory management issues. No idea why this code ever worked on the RR. No redmine, email by Hiram

diff --git src/hg/hgc/bigBedClick.c src/hg/hgc/bigBedClick.c
index 8d016a0..ee32fcf 100644
--- src/hg/hgc/bigBedClick.c
+++ src/hg/hgc/bigBedClick.c
@@ -192,68 +192,72 @@
 /* some extra fields require special printing code, they all start with '_'  */
 {
 if (sameWord(name, "_mismatchCounts"))
     extFieldMismatchCounts(val);
 else if (sameWord(name, "_crisprOfftargets"))
     extFieldCrisprOfftargets(val, extraFields);
 }
 
 static void seekAndPrintTable(char *url, off_t offset, struct slPair *extraFields)
 /* seek to 0 at url, get headers, then seek to offset, read tab-sep fields and output 
  * (extraFields are needed for some special field handlers) */
 {
 char *detailsUrl = replaceChars(url, "$db", database);
 
 // open the URL
-struct lineFile *lf = lineFileUdcMayOpen(detailsUrl, FALSE);
+struct lineFile *lf = lineFileUdcMayOpen(detailsUrl, TRUE);
 if (lf==NULL)
     {
     printf("Error: Could not open the URL referenced in detailsTabUrls, %s", detailsUrl);
     return;
     }
 
 // get the headers
-char *headLine;
-int lineSize;
+char *headLine = NULL;
+int lineSize = 0;
 lineFileNext(lf, &headLine, &lineSize);
 char *headers[1024];
 int headerCount = chopTabs(headLine, headers);
 
+// clone the headers
+int i;
+for (i=0; i<headerCount; i++)
+    headers[i] = cloneString(headers[i]);
+
 lineFileSeek(lf, offset, SEEK_SET);
 
 // read a line
 char *detailsLine;
 lineFileNext(lf, &detailsLine, &lineSize);
 if (!detailsLine || isEmpty(detailsLine))
     return;
 char *fields[1024];
 int fieldCount = chopTabs(detailsLine, fields);
 
 if (fieldCount!=headerCount)
     {
     printf("Error encountered when reading %s:<br>", detailsUrl);
     printf("The header line of the tab-sep file has a different number of fields compared ");
     printf("with the line pointed to by offset %lld in the bigBed file.<br>", (long long int)offset);
     printf("Number of headers: %d", headerCount);
     printf("Number of fields at offset: %d", fieldCount);
     return;
     }
 
 // print the table for all external extra fields 
 printf("<br><table class='bedExtraTbl'>\n");
 fieldCount = min(fieldCount, headerCount);
-int i;
 for (i=0; i<fieldCount; i++)
 {
     char *name = headers[i];
     char *val  = fields[i];
     
     if (startsWith("_", name))
         detailsTabPrintSpecial(name, val, extraFields);
     else
         {
         printf("<tr><td>%s</td>\n", name);
         printf("<td>%s</td></tr>\n", val);
         }
 }
 printf("</table>\n");