48b2f22e167169b687932c7121ca445ea43ba166
tdreszer
  Wed Jun 18 14:05:08 2014 -0700
Angie caught my bug in code review.  Thanks! #13457.
diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index 4df31f6..8a0b52b 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -944,30 +944,31 @@
     char query[1024];
     sqlSafef(query, sizeof(query), sql, itemName);
     struct sqlConnection *conn = hAllocConn(database);
     id = sqlQuickString(conn, query);
     hFreeConn(&conn);
     }
 return id;
 }
 
 char* replaceInUrl(struct trackDb *tdb, char *url, char *idInUrl, boolean encode) 
 /* replace $$ in url with idInUrl. Supports many other wildchards */
 {
 struct dyString *uUrl = NULL;
 struct dyString *eUrl = NULL;
 char startString[64], endString[64];
+char begItem[64], endItem[64];
 char *ins[11], *outs[11];
 char *eItem = (encode ? cgiEncode(idInUrl) : cloneString(idInUrl));
 
 safef(startString, sizeof startString, "%d", winStart);
 safef(endString, sizeof endString, "%d", winEnd);
 ins[0] = "$$";
 outs[0] = idInUrl;
 ins[1] = "$T";
 outs[1] = tdb->track;
 ins[2] = "$S";
 outs[2] = seqName;
 ins[3] = "$[";
 outs[3] = startString;
 ins[4] = "$]";
 outs[4] = endString;
@@ -989,31 +990,30 @@
     outs[8] = suffixClone;
     /* small memory leak here for these cloned strings */
     /* not important for a one-time operation in a CGI that will exit */
 } else {
     outs[7] = idInUrl;	/* otherwise, these are not expected */
     outs[8] = idInUrl;	/* to be used */
 }
 
 // URL may now contain item boundaries
 ins[9] = "${";
 ins[10] = "$}";
 if (cartOptionalString(cart, "o") && cartOptionalString(cart, "t"))
     {
     int itemBeg = cartIntExp(cart, "o") + 1; // Should strip any unexpected commas
     int itemEnd = cartIntExp(cart, "t");
-    char begItem[64], endItem[64];
     safef(begItem, sizeof begItem, "%d", itemBeg);
     safef(endItem, sizeof endItem, "%d", itemEnd);
     outs[9] = begItem;
     outs[10] = endItem;
     }
 else // should never be but I am unwilling to bet the farm
     {
     outs[9] = startString;
     outs[10] = endString;
     }
 
 uUrl = subMulti(url, ArraySize(ins), ins, outs);
 outs[0] = eItem;
 eUrl = subMulti(url, ArraySize(ins), ins, outs);
 freeDyString(&uUrl);