Possible NULL dereference, not sure how to address

12 views
Skip to first unread message

Mark Rotteveel

unread,
Aug 10, 2025, 9:05:12 AMAug 10
to firebir...@googlegroups.com
Looking at Retrieval.cpp, it has this code in InversionNode*
Retrieval::makeIndexScanNode(IndexScratch* indexScratch):

```
// Check whether this is during a compile or during a SET INDEX operation
if (csb)
CMP_post_resource(&csb->csb_resources, relation, Resource::rsc_index,
idx->idx_id);
else
{
CMP_post_resource(&tdbb->getRequest()->getStatement()->resources, relation,
Resource::rsc_index, idx->idx_id);
}

// For external requests, determine index name (to be reported in plans)
QualifiedName indexName;
if (!(csb->csb_g_flags & csb_internal))
MET_lookup_index(tdbb, indexName, relation->rel_name, idx->idx_id + 1);
```

That if has a possible NULL dereference, but I can't tell if the proper
fix is:

```
if (csb && !(csb->csb_g_flags & csb_internal))
```

or

```
if (!(csb && csb->csb_g_flags & csb_internal))
MET_lookup_index(tdbb, indexName, relation->rel_name, idx->idx_id + 1);
```

Any ideas?

Mark
--
Mark Rotteveel

Dimitry Sibiryakov

unread,
Aug 10, 2025, 11:09:37 AMAug 10
to firebir...@googlegroups.com
'Mark Rotteveel' via firebird-devel wrote 10.08.2025 15:05:
> Any ideas?

I would mode declaration of indexName up, above the `if` and the call to
MET_lookup_index() into the `if`.

--
WBR, SD.

Mark Rotteveel

unread,
Aug 10, 2025, 11:58:17 AMAug 10
to firebir...@googlegroups.com
That is assuming that

```
if (csb && !(csb->csb_g_flags & csb_internal))
```

is the right fix, but is it?

Mark
--
Mark Rotteveel
Reply all
Reply to author
Forward
0 new messages