c3cba271647d7a8d2df940be434dc4f1970d2067 max Fri Aug 24 17:40:09 2018 -0700 fixing possible crash in hgc for bigBarChart, no redmine diff --git src/hg/hgc/barChartClick.c src/hg/hgc/barChartClick.c index f8faa88..9c6e08a 100644 --- src/hg/hgc/barChartClick.c +++ src/hg/hgc/barChartClick.c @@ -164,41 +164,46 @@ // Open matrix file struct udcFile *f = udcFileOpen(dataFile, NULL); // Get header line with sample ids char *header = udcReadLine(f); int wordCt = sampleCt+1; // initial field is label or empty char **samples; AllocArray(samples, wordCt); chopByWhite(header, samples, wordCt); // Get data values // Format: id, category, extras bits64 offset = (bits64)bed->_dataOffset; bits64 size = (bits64)bed->_dataLen; +printf("offset %llu, size %llu", offset, size); udcSeek(f, offset); bits64 seek = udcTell(f); if (udcTell(f) != offset) warn("UDC seek mismatch: expecting %Lx, got %Lx. ", offset, seek); char *buf = needMem(size); bits64 count = udcRead(f, buf, size); +printf("buffer %s", buf); if (count != size) warn("UDC read mismatch: expecting %Ld bytes, got %Ld. ", size, count); char **vals; AllocArray(vals, wordCt); -chopByWhite(buf, vals, wordCt); +int gotWordCt = chopByWhite(buf, vals, wordCt); +if (gotWordCt != wordCt) + warn("Matrix format error: expected %d words, but got %d. File %s, on line for gene %s, at offset %llu, with line lenght %llu", wordCt, gotWordCt, dataFile, bed->name, offset, size); + udcFileClose(&f); // Construct list of sample data with category struct barChartItemData *sampleVals = NULL, *data = NULL; int i; for (i=1; i<wordCt && samples[i] != NULL; i++) { char *sample = samples[i]; char *categ = (char *)hashFindVal(sampleHash, sample); if (categ == NULL) warn("barChart track %s: unknown category for sample %s", tdb->track, sample); else if (hashLookup(categoryHash, categ)) { AllocVar(data); data->sample = cloneString(sample);