Fossil SCM
Fix the remote_repo_info() function to avoid resource leaks and to suppress unhelpful error and warning messages.
Commit
1e3cfc1e9eaa2bcb21720e447619906227cf960aef9bc045e6984e187e9c3589
Parent
f392fac705e3ec8…
1 file changed
+6
-3
+6
-3
| --- src/repolist.c | ||
| +++ src/repolist.c | ||
| @@ -45,27 +45,30 @@ | ||
| 45 | 45 | |
| 46 | 46 | pRepo->isValid = 0; |
| 47 | 47 | pRepo->zProjName = 0; |
| 48 | 48 | pRepo->rMTime = 0.0; |
| 49 | 49 | |
| 50 | + g.dbIgnoreErrors++; | |
| 50 | 51 | rc = sqlite3_open(pRepo->zRepoName, &db); |
| 51 | - if( rc ) return; | |
| 52 | + if( rc ) goto finish_repo_list; | |
| 52 | 53 | rc = sqlite3_prepare_v2(db, "SELECT value FROM config" |
| 53 | 54 | " WHERE name='project-name'", |
| 54 | 55 | -1, &pStmt, 0); |
| 55 | - if( rc ) return; | |
| 56 | + if( rc ) goto finish_repo_list; | |
| 56 | 57 | if( sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 57 | 58 | pRepo->zProjName = fossil_strdup((char*)sqlite3_column_text(pStmt,0)); |
| 58 | 59 | } |
| 59 | 60 | sqlite3_finalize(pStmt); |
| 60 | 61 | rc = sqlite3_prepare_v2(db, "SELECT max(mtime) FROM event", -1, &pStmt, 0); |
| 61 | 62 | if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 62 | 63 | pRepo->rMTime = sqlite3_column_double(pStmt,0); |
| 63 | 64 | } |
| 65 | + pRepo->isValid = 1; | |
| 64 | 66 | sqlite3_finalize(pStmt); |
| 67 | +finish_repo_list: | |
| 68 | + g.dbIgnoreErrors--; | |
| 65 | 69 | sqlite3_close(db); |
| 66 | - pRepo->isValid = 1; | |
| 67 | 70 | } |
| 68 | 71 | |
| 69 | 72 | /* |
| 70 | 73 | ** Generate a web-page that lists all repositories located under the |
| 71 | 74 | ** g.zRepositoryName directory and return non-zero. |
| 72 | 75 |
| --- src/repolist.c | |
| +++ src/repolist.c | |
| @@ -45,27 +45,30 @@ | |
| 45 | |
| 46 | pRepo->isValid = 0; |
| 47 | pRepo->zProjName = 0; |
| 48 | pRepo->rMTime = 0.0; |
| 49 | |
| 50 | rc = sqlite3_open(pRepo->zRepoName, &db); |
| 51 | if( rc ) return; |
| 52 | rc = sqlite3_prepare_v2(db, "SELECT value FROM config" |
| 53 | " WHERE name='project-name'", |
| 54 | -1, &pStmt, 0); |
| 55 | if( rc ) return; |
| 56 | if( sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 57 | pRepo->zProjName = fossil_strdup((char*)sqlite3_column_text(pStmt,0)); |
| 58 | } |
| 59 | sqlite3_finalize(pStmt); |
| 60 | rc = sqlite3_prepare_v2(db, "SELECT max(mtime) FROM event", -1, &pStmt, 0); |
| 61 | if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 62 | pRepo->rMTime = sqlite3_column_double(pStmt,0); |
| 63 | } |
| 64 | sqlite3_finalize(pStmt); |
| 65 | sqlite3_close(db); |
| 66 | pRepo->isValid = 1; |
| 67 | } |
| 68 | |
| 69 | /* |
| 70 | ** Generate a web-page that lists all repositories located under the |
| 71 | ** g.zRepositoryName directory and return non-zero. |
| 72 |
| --- src/repolist.c | |
| +++ src/repolist.c | |
| @@ -45,27 +45,30 @@ | |
| 45 | |
| 46 | pRepo->isValid = 0; |
| 47 | pRepo->zProjName = 0; |
| 48 | pRepo->rMTime = 0.0; |
| 49 | |
| 50 | g.dbIgnoreErrors++; |
| 51 | rc = sqlite3_open(pRepo->zRepoName, &db); |
| 52 | if( rc ) goto finish_repo_list; |
| 53 | rc = sqlite3_prepare_v2(db, "SELECT value FROM config" |
| 54 | " WHERE name='project-name'", |
| 55 | -1, &pStmt, 0); |
| 56 | if( rc ) goto finish_repo_list; |
| 57 | if( sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 58 | pRepo->zProjName = fossil_strdup((char*)sqlite3_column_text(pStmt,0)); |
| 59 | } |
| 60 | sqlite3_finalize(pStmt); |
| 61 | rc = sqlite3_prepare_v2(db, "SELECT max(mtime) FROM event", -1, &pStmt, 0); |
| 62 | if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 63 | pRepo->rMTime = sqlite3_column_double(pStmt,0); |
| 64 | } |
| 65 | pRepo->isValid = 1; |
| 66 | sqlite3_finalize(pStmt); |
| 67 | finish_repo_list: |
| 68 | g.dbIgnoreErrors--; |
| 69 | sqlite3_close(db); |
| 70 | } |
| 71 | |
| 72 | /* |
| 73 | ** Generate a web-page that lists all repositories located under the |
| 74 | ** g.zRepositoryName directory and return non-zero. |
| 75 |