3e29ad0059ebf3c9b781ac5317e692ae2a2687bb braney Tue Jan 14 23:31:45 2020 -0800 hgCollection fiddles with the settingsHash of trackDb, which might be cached and made up of memory that shouldn't be freed. Copy the hash before fiddling with it. Found a bug in lmCloneHash (wasn't setting hash->lm correctly, so increment trackDb version just to make sure cache will be cleared. diff --git src/hg/hgCollection/hgCollection.c src/hg/hgCollection/hgCollection.c index 15344c8..1ebab5e 100644 --- src/hg/hgCollection/hgCollection.c +++ src/hg/hgCollection/hgCollection.c @@ -7,30 +7,31 @@ #include "trackHub.h" #include "trashDir.h" #include "hubConnect.h" #include "hui.h" #include "grp.h" #include "cheapcgi.h" #include "jsHelper.h" #include "web.h" #include "knetUdc.h" #include "api.h" #include "genbank.h" #include "htmshell.h" #include "jsonParse.h" #include "customComposite.h" #include "stdlib.h" +#include "localmem.h" /* Tool tips */ #define COLLECTION_TITLE "Double-click to edit name and color" #define FOLDER_TITLE "Click to open node" #define TRACK_TITLE "Press Green Plus to add track to collection" /* Global Variables */ struct hash *oldVars = NULL; /* The cart before new cgi stuff added. */ // Null terminated list of CGI Variables we don't want to save permanently: char *excludeVars[] = {"Submit", "submit", "cmd", "track", "collection", "jsonp", NULL,}; struct track { struct track *next; struct track *trackList; @@ -717,30 +718,32 @@ if (collection->trackList == NULL) // don't output composites without children continue; struct trackDb *tdb = createComposite(collection->name, collection->shortLabel, collection->longLabel, collection->color, priority++); struct dyString *dy = trackDbString(tdb); fprintf(f, "%s\n", dy->string); struct track *track; for (track = collection->trackList; track; track = track->next) { tdb = hashMustFindVal(nameHash, track->name); saveTrackName(tdb, hubName, collectionNameHash); char colorString[64]; safef(colorString, sizeof colorString, "%ld,%ld,%ld", (track->color >> 16) & 0xff,(track->color >> 8) & 0xff,track->color & 0xff); + struct lm *lm = lmInit(4096); + tdb->settingsHash = lmCloneHash(lm, tdb->settingsHash); hashReplace(tdb->settingsHash, "color", colorString); hashReplace(tdb->settingsHash, "shortLabel", track->shortLabel); hashReplace(tdb->settingsHash, "longLabel", track->longLabel); hashReplace(tdb->settingsHash, "track", makeUniqueName(collectionNameHash, track->name)); hashReplace(tdb->settingsHash, "parent", collection->name); printTdbToHub(db, conn, f, tdb, 1, priority++); } } fclose(f); hFreeConn(&conn); } static unsigned long hexStringToLong(char *str)