diff options
author | jbj <devnull@localhost> | 2005-03-20 15:53:26 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2005-03-20 15:53:26 +0000 |
commit | 7154555008deb164c8a14ffe0573554dc2ecb25b (patch) | |
tree | bf2b1475778c767cc31a900a572626594f6d9148 /rpmdb | |
parent | 0f21a8eda09b5ff120243f882b558327aaa2ef71 (diff) | |
download | rpm-7154555008deb164c8a14ffe0573554dc2ecb25b.tar.gz rpm-7154555008deb164c8a14ffe0573554dc2ecb25b.tar.bz2 rpm-7154555008deb164c8a14ffe0573554dc2ecb25b.zip |
Check that dbcursor is always non-null.
CVS patchset: 7827
CVS date: 2005/03/20 15:53:26
Diffstat (limited to 'rpmdb')
-rw-r--r-- | rpmdb/sqlite.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/rpmdb/sqlite.c b/rpmdb/sqlite.c index d9023a2e8..8689b038d 100644 --- a/rpmdb/sqlite.c +++ b/rpmdb/sqlite.c @@ -1090,25 +1090,29 @@ static int sql_cget (dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DB * db = dbi->dbi_db; /*@i@*/ SQL_DB * sqldb = (SQL_DB *)db->app_private; SCP_t scp; - int cleanup = 0; + int copen_done = 0; int rc = 0; assert(sqldb->db != NULL); dbg_keyval(__FUNCTION__, dbi, dbcursor, key, data, flags); +/* XXX modern rpm always uses copen/cclose. */ +assert(dbcursor != NULL); if ( dbcursor == NULL ) { rc = sql_copen ( dbi, NULL, &dbcursor, 0 ); - cleanup = 1; + copen_done = 1; } /* Find our version of the db3 cursor */ scp = sqldb->head_cursor; +/* XXX no need to chain cursors with copen/cclose. */ +assert(scp != NULL && scp->name == dbcursor); while ( scp != NULL && scp->name != dbcursor ) { scp = scp->next; } - assert(scp != NULL); +assert(scp != NULL); if (noisy) fprintf(stderr, "\tcget(%s) scp %p\n", dbi->dbi_subfile, scp); @@ -1117,7 +1121,7 @@ fprintf(stderr, "\tcget(%s) scp %p\n", dbi->dbi_subfile, scp); * scan the whole DB */ - if ( rc == 0 && key->size == 0 ) { + if (rc == 0 && key->size == 0) { scp->all++; } @@ -1181,11 +1185,13 @@ fprintf(stderr, "\tcget(%s) got %d rows, %d columns\n", dbi->dbi_subfile, scp->nr, scp->nc); } - if (rc == 0 && ! scp->av) + if (rc == 0 && scp->av == NULL) rc = DB_NOTFOUND; repeat: - if ( rc == 0 ) { + if (rc != 0) + goto exit; + { scp->rx++; if ( scp->rx > scp->nr ) rc = DB_NOTFOUND; /* At the end of the list */ @@ -1247,12 +1253,13 @@ fprintf(stderr, "\tcget(%s) found data 0x%x (%d)\n", dbi->dbi_subfile, } } +exit: if (rc == DB_NOTFOUND) { if (_debug) fprintf(stderr, "\tcget(%s) not found\n", dbi->dbi_subfile); } - if (cleanup) + if (copen_done) /*@-temptrans@*/ (void) sql_cclose(dbi, dbcursor, 0); /*@=temptrans@*/ return rc; |