lmdbn/badgern: fix for tag array crashes on query planner.

This commit is contained in:
fiatjaf 2023-09-16 15:51:41 -03:00
parent 8968982b9a
commit 24d1e3aebd
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1
2 changed files with 16 additions and 2 deletions

View File

@ -248,7 +248,14 @@ func prepareQueries(filter nostr.Filter) (
extraFilter = &nostr.Filter{Tags: filter.Tags}
} else if len(filter.Tags) > 0 {
index = indexTagPrefix
queries = make([]query, len(filter.Tags))
// determine the size of the queries array by inspecting all tags sizes
size := 0
for _, values := range filter.Tags {
size += len(values)
}
queries = make([]query, size)
extraFilter = &nostr.Filter{Kinds: filter.Kinds}
i := 0
for _, values := range filter.Tags {

View File

@ -253,7 +253,14 @@ func (b *LMDBBackend) prepareQueries(filter nostr.Filter) (
extraFilter = &nostr.Filter{Tags: filter.Tags}
} else if len(filter.Tags) > 0 {
dbi = b.indexTag
queries = make([]query, len(filter.Tags))
// determine the size of the queries array by inspecting all tags sizes
size := 0
for _, values := range filter.Tags {
size += len(values)
}
queries = make([]query, size)
extraFilter = &nostr.Filter{Kinds: filter.Kinds}
i := 0
for _, values := range filter.Tags {