From 994bfcd2858eadf8317c883971c6ef1042887c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 6 Feb 2019 22:36:12 +0200 Subject: [PATCH] MXS-2268: Fix undefined behavior Using a void return value as an integer results in undefined behavior. apparently in this case it doesn't translate into a crash and instead only manifests itself when all the planets align. --- query_classifier/qc_sqlite/qc_sqlite.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/query_classifier/qc_sqlite/qc_sqlite.cc b/query_classifier/qc_sqlite/qc_sqlite.cc index 55755d515..b993c8361 100644 --- a/query_classifier/qc_sqlite/qc_sqlite.cc +++ b/query_classifier/qc_sqlite/qc_sqlite.cc @@ -3282,7 +3282,7 @@ extern void maxscale_update_function_info(const char* name, const Expr* pExpr); // 'unsigned int' and not 'uint32_t' because 'uint32_t' is unknown in sqlite3 context. extern void maxscale_set_type_mask(unsigned int type_mask); -extern void maxscaleComment(); +extern int maxscaleComment(); extern int maxscaleKeyword(int token); extern int maxscaleTranslateKeyword(int token); @@ -4080,14 +4080,18 @@ void maxscaleCreateSequence(Parse* pParse, Token* pDatabase, Token* pTable) QC_EXCEPTION_GUARD(pInfo->maxscaleCreateSequence(pParse, pDatabase, pTable)); } -void maxscaleComment() +int maxscaleComment() { QC_TRACE(); QcSqliteInfo* pInfo = this_thread.pInfo; ss_dassert(pInfo); - QC_EXCEPTION_GUARD(pInfo->maxscaleComment()); + int rc = 0; + + QC_EXCEPTION_GUARD(rc = pInfo->maxscaleComment()); + + return rc; } void maxscaleDeclare(Parse* pParse)