0df623bc76a0c81c38aed0ea9945808a605935b6
kate
  Thu May 18 17:01:41 2017 -0700
Protect against bad barChart files (where #expScores doesn't match expCount. refs #18736

diff --git src/lib/basicBed.c src/lib/basicBed.c
index b0fca2a..63e10f5 100644
--- src/lib/basicBed.c
+++ src/lib/basicBed.c
@@ -1629,31 +1629,45 @@
 	enum asTypes type = asCol->lowType->type;
 	if (! (asCol->isList || asCol->isArray))
 	    {
 	    if (asTypesIsInt(type))
 		lineFileAllInts(lf, row, i, NULL, !asTypesIsUnsigned(type), asTypesIntSize(type), asTypesIntSizeDescription(type), FALSE);
 	    else if (asTypesIsFloating(type))
 		lineFileNeedDouble(lf, row, i);
 	    else if (type == t_string)
 		{
 		if (strlen(row[i]) > 255)
 		    lineFileAbort(lf, "expecting length (%llu) of string (%s) not to exceed 255 in field %s", (unsigned long long)strlen(row[i]), row[i], asCol->name);
 		}
 	    }
 	else if (asCol->isList)
 	    {
-	    if (asTypesIsInt(type))
+            if (asTypesIsFloating(type))
+                {
+                // assure count = #items in list; lightweight validation (better than none)
+                int ix = asColumnFindIx(as->columnList, asCol->linkedSizeName);
+                int count = sqlUnsigned(row[ix]);
+		if (count == 0)
+                    lineFileAbort(lf, 
+                        "expecting positive number in count field for %s list, found %d", 
+                                        asCol->name, asCol->fixedSize);
+                int itemCount = countSeparatedItems(row[i], ',');
+                if (count != itemCount)
+                    lineFileAbort(lf, "expecting %d elements in %s list, found %d", 
+                                        count, asCol->name, itemCount);
+                }
+	    else if (asTypesIsInt(type))
 		{
 		count = lineFileAllIntsArray(lf, row, i, NULL, countSeparatedItems(row[i], ','),
 		    !asTypesIsUnsigned(type), asTypesIntSize(type), asTypesIntSizeDescription(type), FALSE);
 		if (asCol->fixedSize > 0)
 		    {
 		    if (asCol->fixedSize != count)
 			lineFileAbort(lf, "expecting %d elements in %s list, found %d", asCol->fixedSize, asCol->name, count);
 		    }
 		else
 		    {
 		    if (!linkHash)
 			lineFileAbort(lf, "linked field %s was not found; it is required for determining listSize of %s"
 			    , asCol->linkedSizeName, asCol->name);
 		    int listSize = hashIntValDefault(linkHash, asCol->linkedSizeName, -1);
 		    if (listSize == -1)