Fossil SCM

Fix the remote_repo_info() function to avoid resource leaks and to suppress unhelpful error and warning messages.

drh 2019-01-10 18:25 trunk
Commit 1e3cfc1e9eaa2bcb21720e447619906227cf960aef9bc045e6984e187e9c3589
1 file changed +6 -3
+6 -3
--- src/repolist.c
+++ src/repolist.c
@@ -45,27 +45,30 @@
4545
4646
pRepo->isValid = 0;
4747
pRepo->zProjName = 0;
4848
pRepo->rMTime = 0.0;
4949
50
+ g.dbIgnoreErrors++;
5051
rc = sqlite3_open(pRepo->zRepoName, &db);
51
- if( rc ) return;
52
+ if( rc ) goto finish_repo_list;
5253
rc = sqlite3_prepare_v2(db, "SELECT value FROM config"
5354
" WHERE name='project-name'",
5455
-1, &pStmt, 0);
55
- if( rc ) return;
56
+ if( rc ) goto finish_repo_list;
5657
if( sqlite3_step(pStmt)==SQLITE_ROW ){
5758
pRepo->zProjName = fossil_strdup((char*)sqlite3_column_text(pStmt,0));
5859
}
5960
sqlite3_finalize(pStmt);
6061
rc = sqlite3_prepare_v2(db, "SELECT max(mtime) FROM event", -1, &pStmt, 0);
6162
if( rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW ){
6263
pRepo->rMTime = sqlite3_column_double(pStmt,0);
6364
}
65
+ pRepo->isValid = 1;
6466
sqlite3_finalize(pStmt);
67
+finish_repo_list:
68
+ g.dbIgnoreErrors--;
6569
sqlite3_close(db);
66
- pRepo->isValid = 1;
6770
}
6871
6972
/*
7073
** Generate a web-page that lists all repositories located under the
7174
** g.zRepositoryName directory and return non-zero.
7275
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button