From 14362533bb50596049f1b46bcc6d333208576a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sun, 8 Sep 2019 12:17:44 +0200 Subject: [PATCH] Check for empty expression properly The old code was a left-over from the times when the `capturedExpression` member was a `const char*`, which could always be indexed. With the change to use `StringRef`, blindly indexing 0th element is invalid, as it is not indexable part of a StringRef. --- include/internal/catch_assertionresult.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/internal/catch_assertionresult.cpp b/include/internal/catch_assertionresult.cpp index 4ce07187..8f505d04 100644 --- a/include/internal/catch_assertionresult.cpp +++ b/include/internal/catch_assertionresult.cpp @@ -45,7 +45,7 @@ namespace Catch { } bool AssertionResult::hasExpression() const { - return m_info.capturedExpression[0] != 0; + return !m_info.capturedExpression.empty(); } bool AssertionResult::hasMessage() const {