[BugFix] tagcache_search() must be closed with tagcache_search_finish()

fix a couple of places where this could be left open

Change-Id: I43ac7d6b26d728c11f96e5415710341d60f07ab8
This commit is contained in:
William Wilgus 2024-09-25 01:33:47 -04:00
parent a0e95c888d
commit 9af325a541
2 changed files with 7 additions and 0 deletions

View file

@ -1218,7 +1218,10 @@ static int create_album_untagged(struct tagcache_search *tcs,
{ {
if (rb->button_get(false) > BUTTON_NONE) { if (rb->button_get(false) > BUTTON_NONE) {
if (confirm_quit()) if (confirm_quit())
{
rb->tagcache_search_finish(tcs);
return ERROR_USER_ABORT; return ERROR_USER_ABORT;
}
else else
{ {
rb->lcd_clear_display(); rb->lcd_clear_display();

View file

@ -970,6 +970,7 @@ static int find_index(const char *filename)
bool tagcache_find_index(struct tagcache_search *tcs, const char *filename) bool tagcache_find_index(struct tagcache_search *tcs, const char *filename)
{ {
/* NOTE: on ret==true you need to call tagcache_search_finish(tcs) yourself */
int idx_id; int idx_id;
if (!tc_stat.ready) if (!tc_stat.ready)
@ -1721,6 +1722,7 @@ static bool build_lookup_list(struct tagcache_search *tcs)
bool tagcache_search(struct tagcache_search *tcs, int tag) bool tagcache_search(struct tagcache_search *tcs, int tag)
{ {
/* NOTE: call tagcache_search_finish(&tcs) when finished or BAD things may happen (TM) */
struct tagcache_header tag_hdr; struct tagcache_header tag_hdr;
struct master_header master_hdr; struct master_header master_hdr;
int i; int i;
@ -3936,6 +3938,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs)
if (clfd < 0) if (clfd < 0)
{ {
logf("failure to open changelog"); logf("failure to open changelog");
tagcache_search_finish(tcs);
return false; return false;
} }
@ -3944,6 +3947,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs)
if ( (tcs->masterfd = open_master_fd(&myhdr, false)) < 0) if ( (tcs->masterfd = open_master_fd(&myhdr, false)) < 0)
{ {
close(clfd); close(clfd);
tagcache_search_finish(tcs);
return false; return false;
} }
} }