f12825443a141899e3b713a08b759377c0d8bcbf angie Thu Apr 4 13:51:53 2019 -0700 Prevent segv when a vcfTabix custom track is specified with type=vcf instead. refs #23248 When type=vcf, we expect uncompressed VCF data to follow. But when a track line has type=vcf and no data after that, cpp->fileStack is popped to NULL while we're looking for header lines. So, check for NULL, and if we see the use of bigDataUrl, add a suggestion to use vcfTabix. diff --git src/hg/lib/customFactory.c src/hg/lib/customFactory.c index 8e8bcec..143203d 100644 --- src/hg/lib/customFactory.c +++ src/hg/lib/customFactory.c @@ -3193,32 +3193,46 @@ makeItemsLoader, }; /*** VCF Factory - for Variant Call Format tracks ***/ static boolean vcfRecognizer(struct customFactory *fac, struct customPp *cpp, char *type, struct customTrack *track) /* Return TRUE if looks like we're handling a vcf track */ { if (type != NULL && !sameType(type, fac->name)) return FALSE; boolean isVcf = headerStartsWith(cpp, "##fileformat=VCFv"); if (type != NULL && !isVcf) - lineFileAbort(cpp->fileStack, "type is '%s' but header does not start with '##fileformat=VCFv'", - type); + { + if (cpp->fileStack) + lineFileAbort(cpp->fileStack, + "type is '%s' but header does not start with '##fileformat=VCFv'", type); + else + { + if (isNotEmpty(trackDbSetting(track->tdb, "bigDataUrl"))) + errAbort("type is '%s' but can't find header with '##fileformat=VCFv' " + "following track line. " + "(For bgzip-compressed VCF+tabix index, please use 'type=vcfTabix' " + "instead of 'type=%s')", type, type); + else + errAbort("type is '%s' but can't find header with '##fileformat=VCFv' " + "following track line", type); + } + } return isVcf; } static void vcfLoaderAddDbTable(struct customTrack *track, char *vcfFile) /* Create a database table that points to vcf tab file */ { customFactorySetupDbTrack(track); char *table = track->dbTableName; struct dyString *tableSql = sqlDyStringCreate("CREATE TABLE %s (fileName varchar(255) not null)", table); struct sqlConnection *conn = hAllocConn(CUSTOM_TRASH); sqlRemakeTable(conn, table, tableSql->string); dyStringClear(tableSql); sqlDyStringPrintf(tableSql, "INSERT INTO %s VALUES('%s')", table, vcfFile); sqlUpdate(conn, tableSql->string);