summaryrefslogtreecommitdiff
path: root/apps/tagtree.c
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-05-02 16:48:19 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-05-02 16:48:19 +0100
commitb79eefc8583536da9faa87b50d82eaef8a3e0dde (patch)
tree1f694ae914985df2164b61ba239a733a50a10a45 /apps/tagtree.c
parent6e37b318510d66fc6ec7e94f350062279b242afb (diff)
downloadrockbox-b79eefc8583536da9faa87b50d82eaef8a3e0dde.tar.gz
rockbox-b79eefc8583536da9faa87b50d82eaef8a3e0dde.zip
apps: fix tagtree arithmetic on null pointers
It was possible for the tag tree's buflib move callback to turn a null pointer non-null. The tagcache_search_clause->str can be null for OR clauses. Also ensure that clauses are zeroed on allocation to ensure garbage pointers don't creep in. Change-Id: Ic823a8eecc501eeaa75798066521e427a9a89190
Diffstat (limited to 'apps/tagtree.c')
-rw-r--r--apps/tagtree.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 9fb2172e57..45d2bb991b 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -223,7 +223,8 @@ static int move_callback(int handle, void* current, void* new)
223 { 223 {
224 for(int l = 0; l < mentry->si.clause_count[k]; l++) 224 for(int l = 0; l < mentry->si.clause_count[k]; l++)
225 { 225 {
226 UPDATE(mentry->si.clause[k][l]->str, diff); 226 if(mentry->si.clause[k][l]->str)
227 UPDATE(mentry->si.clause[k][l]->str, diff);
227 UPDATE(mentry->si.clause[k][l], diff); 228 UPDATE(mentry->si.clause[k][l], diff);
228 } 229 }
229 } 230 }
@@ -702,7 +703,7 @@ static int get_condition(struct search_instruction *inst)
702 return -2; 703 return -2;
703 } 704 }
704 705
705 new_clause = tagtree_alloc(sizeof(struct tagcache_search_clause)); 706 new_clause = tagtree_alloc0(sizeof(struct tagcache_search_clause));
706 if (!new_clause) 707 if (!new_clause)
707 { 708 {
708 logf("tagtree failed to allocate %s", "search clause"); 709 logf("tagtree failed to allocate %s", "search clause");