30828d4d517c4dd825ba9d7326c13527e29e9a94
kent
  Thu Apr 4 22:53:13 2013 -0700
Fixed bug where bed loader was segfaulting on beds with less than 9 fields.
diff --git src/lib/basicBed.c src/lib/basicBed.c
index 3c23a7a..817795b 100644
--- src/lib/basicBed.c
+++ src/lib/basicBed.c
@@ -458,30 +458,31 @@
 struct bed *list = NULL;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *line, *row[bedKnownFields];
 int fieldCount = 0;
 boolean isRgb = FALSE;
 
 while (lineFileNextReal(lf, &line))
     {
     int numFields = chopByWhite(line, row, ArraySize(row));
     if (numFields < 4)
 	errAbort("file %s doesn't appear to be in bed format. At least 4 fields required, got %d", 
 		fileName, numFields);
     if (fieldCount == 0)
 	{
         fieldCount = numFields;
+	if (fieldCount >= 9)
 	isRgb =  (strchr(row[8], ',') != NULL);
 	}
     else
         if (fieldCount != numFields)
 	    errAbort("Inconsistent number of fields in file. %d on line %d of %s, %d previously.",
 	        numFields, lf->lineIx, lf->fileName, fieldCount);
     slAddHead(&list, bedLoadN(row, fieldCount));
     }
 lineFileClose(&lf);
 slReverse(&list);
 *retList = list;
 *retFieldCount = fieldCount;
 if (retRgb != NULL)
    *retRgb = isRgb;
 }