815bce4cc505b607c7178d06d45f52d864aa0584
braney
  Fri Jan 28 09:00:34 2022 -0800
fix memory access problem in custom maf support

diff --git src/hg/lib/customFactory.c src/hg/lib/customFactory.c
index 64ed3c8..2d7b549 100644
--- src/hg/lib/customFactory.c
+++ src/hg/lib/customFactory.c
@@ -2229,33 +2229,33 @@
 
 struct pipeline *dataPipe =  pipelineOpen(cmds,
     pipelineWrite | pipelineNoAbort, "/dev/null", track->dbStderrFile, 0);
 if(pipelineWait(dataPipe))
     pipelineFailExit(track);	/* prints error and exits */
 
 pipelineFree(&dataPipe);
 unlink(track->dbStderrFile);	/* no errors, not used */
 track->wigFile = NULL;
 
 struct lineFile *lf = lineFileOpen(tn.forCgi, TRUE);
 char *line;
 int size;
 
 lineFileNeedNext(lf, &line, &size);
+ctAddToSettings(track, "firstItemPos", cloneString(line));
 lineFileClose(&lf);
 unlink(tn.forCgi);
-ctAddToSettings(track, "firstItemPos", cloneString(line));
 }
 
 static struct customTrack *mafLoader(struct customFactory *fac,
 	struct hash *chromHash,
     	struct customPp *cpp, struct customTrack *track, boolean dbRequested)
 {
 FILE *f;
 char *line;
 struct tempName tn;
 struct hash *settings = track->tdb->settingsHash;
 
 if (!dbRequested)
     errAbort("Maf files have to be in database");
 
 if (! fileExists("loader/hgLoadMaf") )