c63d99f6d729517271a0813a8e52f32b18812943
galt
  Mon Jul 23 14:56:17 2018 -0700
Fixes #21801 a bug reported by a user, caused by not freeing the results set early enough.

diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index 481bdec..84e8106 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -21350,30 +21350,31 @@
     if ((table = strchr(thisDb, '.')) != NULL)
 	{
 	*table++ = 0;
 	if (hTableExists(thisDb, table))
 	    {
 	    if (!isCe && (ptr = strchr(acc, '.')))
 		*ptr = 0;
 	    sqlSafef(query, sizeof(query), "select geneId, extra1, refPos from %s where acc = '%s'", blastRef, acc);
 	    sr = sqlGetResult(conn, query);
 	    if ((row = sqlNextRow(sr)) != NULL)
 		{
 		useName = row[0];
 		prot = row[1];
 		pos = row[2];
 		}
+	    sqlFreeResult(&sr);
 	    }
         }
     }
 else if ((pos = strchr(acc, '.')) != NULL)
     {
     *pos++ = 0;
     if ((gene = strchr(pos, '.')) != NULL)
 	{
 	*gene++ = 0;
 	useName = gene;
 	if (!isDm && !isCe && ((prot = strchr(gene, '.')) != NULL))
 	    *prot++ = 0;
 	}
     }
 if (isDm == TRUE)
@@ -21497,31 +21498,30 @@
             printf("<A HREF=\"%s&position=%s:%d-%d&db=%s&ss=%s+%s\">",
                    hgTracksPathAndSettings(),
                    psl->tName, psl->tStart + 1, psl->tEnd, database,
 		   tdb->track, itemName);
 	    sprintLongWithCommas(startBuf, psl->tStart + 1);
 	    sprintLongWithCommas(endBuf, psl->tEnd);
 	    printf("%s:%s-%s</A> <BR>",psl->tName,startBuf, endBuf);
 	    if (isClicked)
 		printf("\n");
 	    }
 	}
     }
     printf("</PRE></TT>");
     /* Add description */
     printTrackHtml(tdb);
-    sqlFreeResult(&sr);
     hFreeConn(&conn);
 }
 
 static void doSgdOther(struct trackDb *tdb, char *item)
 /* Display information about other Sacchromyces Genome Database
  * other (not-coding gene) info. */
 {
 struct sqlConnection *conn = hAllocConn(database);
 struct dyString *dy = dyStringNew(1024);
 if (sqlTableExists(conn, "sgdOtherDescription"))
     {
     /* Print out description and type if available. */
     struct sgdDescription sgd;
     struct sqlResult *sr;
     char query[256], **row;