196f6933bbd781e74d3d63203b7d6d4ad3ad6eac angie Tue Sep 10 14:39:42 2019 -0700 Add NULL check in case a customTrash wiggle table has no rows. I haven't found a way to recreate an empty wiggle table with the CGIs, only manually, but there was one case of this in the >100,000 old sessions on the RR. diff --git src/hg/hgSession/sessionData.c src/hg/hgSession/sessionData.c index bdccdf4..f8a34a1 100644 --- src/hg/hgSession/sessionData.c +++ src/hg/hgSession/sessionData.c @@ -282,41 +282,44 @@ * NOTE: this supports only wiggle, maf and vcf customTrash tables, and relies * on the assumption that each customTrash table refers to only one trash path in all rows. */ { if (sessionDir) { struct sqlConnection *conn = hAllocConn(CUSTOM_TRASH); int ix; for (ix = 0; ix < ArraySize(fileColumnNames); ix++) { char *columnName = fileColumnNames[ix]; if (sqlFieldIndex(conn, tableName, columnName) >= 0) { struct dyString *dy = sqlDyStringCreate("select %s from %s limit 1", columnName, tableName); char *trashPath = sqlQuickString(conn, dy->string); + if (trashPath) + { // For some reason, customTrash tables' filename paths can begin with "./../trash" char *actualTrashPath = trashPath; if (startsWith("./", trashPath) && isTrashPath(trashPath+2)) actualTrashPath = trashPath+2; if (isTrashPath(actualTrashPath)) { char *newPath = saveTrashFile(actualTrashPath, sessionDir); if (newPath) replaceColumnValue(conn, tableName, columnName, newPath); freeMem(newPath); } + } dyStringFree(&dy); freeMem(trashPath); break; } } hFreeConn(&conn); } } static void saveDbTableName(char **retString, char *sessionDataDbPrefix, char *dbSuffix, char *sessionDir) /* If sessionDataDbPrefix is given then scan for dbTableName setting; if found, move table and * update retString with new location. Also, if table contains a trash path and sessionDir * is given, then replace the old trash path in the table with the new sessionDir location. */ {