aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2026-10-13 03:39:20 +0200
committerNIIBE Yutaka <[email protected]>2026-10-13 03:39:20 +0200
commitda3bf055c7a3c0b0ee092b369ddb7f2fe01d75af (patch)
tree2b7ae690271f2c65bdaa844d1827e9bd7bf2c186
parenttests: Add a sample keypair from RFC9882. (diff)
downloadgnupg-da3bf055c7a3c0b0ee092b369ddb7f2fe01d75af.tar.gz
gnupg-da3bf055c7a3c0b0ee092b369ddb7f2fe01d75af.zip
gpg:tdbio: Release the lock on error path.
* g10/tdbio.c (put_record_into_cache): Call release_write_lock. (tdbio_sync): Likewise. -- Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--g10/tdbio.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/g10/tdbio.c b/g10/tdbio.c
index e74dcb6b6..2a2da494b 100644
--- a/g10/tdbio.c
+++ b/g10/tdbio.c
@@ -374,7 +374,10 @@ put_record_into_cache (ulong recno, const char *data)
rc = write_cache_item (r);
if (rc)
- return rc;
+ {
+ release_write_lock ();
+ return rc;
+ }
if (!unused)
unused = r;
r->flags.used = 0;
@@ -419,23 +422,29 @@ tdbio_sync (void)
CACHE_CTRL r;
if( db_fd == -1 )
- open_db();
+ open_db();
+
#if 0 /* Transactions are not yet used. */
if( in_transaction )
- log_bug("tdbio: syncing while in transaction\n");
+ log_bug("tdbio: syncing while in transaction\n");
#endif
if( !cache_is_dirty )
- return 0;
+ return 0;
take_write_lock ();
- for( r = cache_list; r; r = r->next ) {
- if( r->flags.used && r->flags.dirty ) {
+ for( r = cache_list; r; r = r->next )
+ {
+ if( r->flags.used && r->flags.dirty )
+ {
int rc = write_cache_item( r );
if( rc )
+ {
+ release_write_lock ();
return rc;
- }
- }
+ }
+ }
+ }
cache_is_dirty = 0;
release_write_lock ();