MXS-3120 Check whether sqlite SrcList is NULL

According to bug-report it seems that a SrcList can be NULL. This
fixes the immediate problem, but it would be good to know in what
contexts the SrcList can be NULL so that the check could be made
before calling the function instead of checking (possibly
unnecessarily at times) in the function.
This commit is contained in:
Johan Wikman 2020-08-19 15:41:29 +03:00
parent b5fa26e8a6
commit bf6ff8a578

View File

@ -1407,16 +1407,19 @@ public:
void update_names_from_srclist(QcAliases* pAliases,
const SrcList* pSrc)
{
for (int i = 0; i < pSrc->nSrc; ++i)
if (pSrc) // TODO: Figure out in what contexts pSrc can be NULL.
{
if (pSrc->a[i].zName)
for (int i = 0; i < pSrc->nSrc; ++i)
{
update_names(pSrc->a[i].zDatabase, pSrc->a[i].zName, pSrc->a[i].zAlias, pAliases);
}
if (pSrc->a[i].zName)
{
update_names(pSrc->a[i].zDatabase, pSrc->a[i].zName, pSrc->a[i].zAlias, pAliases);
}
if (pSrc->a[i].pSelect && pSrc->a[i].pSelect->pSrc)
{
update_names_from_srclist(pAliases, pSrc->a[i].pSelect->pSrc);
if (pSrc->a[i].pSelect && pSrc->a[i].pSelect->pSrc)
{
update_names_from_srclist(pAliases, pSrc->a[i].pSelect->pSrc);
}
}
}
}