037c833e8dca55aac30d9e6e0c40338239522eb3
angie
  Fri Feb 7 17:03:23 2014 -0800
Adding missing NULL check.  On hgwdev, without this fix we get a SEGV:- cartReset
- hgTables
- change group to "all tables" --> page draws halfway
Fortunately I don't see that on hgwbeta.

diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c
index db4d7ef..925765e 100644
--- src/hg/lib/jksql.c
+++ src/hg/lib/jksql.c
@@ -1039,34 +1039,36 @@
  * profileName, database, or both. The profile is the prefix to the host,
  * user, and password variables in .hg.conf.  For the default profile of "db",
  * the environment variables HGDB_HOST, HGDB_USER, and HGDB_PASSWORD can
  * override.
  */
 {
 struct sqlProfile* sp = sqlProfileMustGet(profileName, database);
 return sqlConnRemote(sp->host, sp->port, sp->socket, sp->user, sp->password, database, TRUE);
 }
 
 struct sqlConnection *sqlMayConnectProfile(char *profileName, char *database)
 /* Connect to profile or database using the specified profile. Can specify
  * profileName, database, or both. The profile is the prefix to the host,
  * user, and password variables in .hg.conf.  For the default profile of "db",
  * the environment variables HGDB_HOST, HGDB_USER, and HGDB_PASSWORD can
- * override.  Return NULL if connection fails.
+ * override.  Return NULL if connection fails or profile is not found.
  */
 {
 struct sqlProfile* sp = sqlProfileGet(profileName, database);
+if (sp == NULL)
+    return NULL;
 return sqlConnRemote(sp->host, sp->port, sp->socket, sp->user, sp->password, database, FALSE);
 }
 
 void sqlVaWarn(struct sqlConnection *sc, char *format, va_list args)
 /* Default error message handler. */
 {
 MYSQL *conn = sc->conn;
 if (format != NULL) {
     vaWarn(format, args);
     }
 warn("mySQL error %d: %s (profile=%s, host=%s, db=%s)", mysql_errno(conn), 
     mysql_error(conn), scConnProfile(sc), sqlGetHost(sc), scConnDb(sc));
 }
 
 void sqlWarn(struct sqlConnection *sc, char *format, ...)