fe3f52d294f42461f732844e254e8f0caa8990ab angie Fri Dec 8 08:56:32 2023 -0800 Adding a NULL check, HT braney in code review #32706 diff --git src/hg/hgTables/bigBed.c src/hg/hgTables/bigBed.c index 2b63ccc..0feb564 100644 --- src/hg/hgTables/bigBed.c +++ src/hg/hgTables/bigBed.c @@ -164,43 +164,44 @@ struct bbiFile *bbi = bigBedFileOpenAlias(fileName, chromAliasFindAliases); struct asObject *as = bigBedAsOrDefault(bbi); struct asFilter *filter = asFilterFromCart(cart, db, table, as); struct bed *bedList = NULL; /* If we're doing a whole-genome query with a name index then use the name index to retrieve items * instead of iterating over regions. */ struct hash *idHash = NULL; if (bbi->definedFieldCount >= 4) idHash = identifierHash(db, table); int fieldIx; struct bptFile *bpt = NULL; struct lm *bbLm = NULL; struct bigBedInterval *ivList = NULL; if (idHash && isRegionWholeGenome()) - { bpt = bigBedOpenExtraIndex(bbi, "name", &fieldIx); - struct slName *nameList = hashSlNameFromHash(idHash); +if (bpt != NULL) + { + struct slName *nameList = hashSlNameFromHash(idHash), *name; int count = slCount(nameList); char *names[count]; int ii; - for (ii=0; ii < count; ii++) + for (ii=0, name = nameList; ii < count; ii++, name = name->next) { - names[ii] = nameList->name; - nameList = nameList->next; + names[ii] = name->name; } bbLm = lmInit(0); ivList = bigBedMultiNameQuery(bbi, bpt, fieldIx, names, count, bbLm); + slNameFreeList(&nameList); } struct region *region; for (region = regionList; region != NULL; region = region->next) { if (bpt) { /*** NOTE: it is inefficient to convert intervals from a name-index query to filtered bed * inside the loop on regionList. However, bigBedGetFilteredBedsOnRegions is called by * getFilteredBeds on a "regionList" that has been doctored to one region at a time, * so we can do intersection one region at a time. Since this is called once per region, * we really do need to restrict items to region->chrom, otherwise all items would be * returned for every region. It is still much more efficient for large bigBeds to do * name-index queries when names are pasted/uploaded than to fetch all intervals in all * regions and then check names. See MLQ #32625. */ char chromBuf[4096];