From bf6ff8a5788d60e049c9ab9ea5465a9b1039f4e0 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 19 Aug 2020 15:41:29 +0300 Subject: [PATCH] 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. --- query_classifier/qc_sqlite/qc_sqlite.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/query_classifier/qc_sqlite/qc_sqlite.cc b/query_classifier/qc_sqlite/qc_sqlite.cc index cc772c615..864c48683 100644 --- a/query_classifier/qc_sqlite/qc_sqlite.cc +++ b/query_classifier/qc_sqlite/qc_sqlite.cc @@ -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); + } } } }