summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-03-26 16:40:27 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-03-26 20:41:12 +0100
commit65b99967c4da8e57ebabc9bed98818750fc82038 (patch)
treee8f89a0c2a21a909703ac8f1756b2625127f4a2c
parentcid#1242796 Untrusted loop bound (diff)
downloadcore-65b99967c4da8e57ebabc9bed98818750fc82038.tar.gz
core-65b99967c4da8e57ebabc9bed98818750fc82038.zip
split this to give a sanitizing return pass through
Change-Id: I81eba14e31fe12fc92403c15e5d46f0493022f50 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113169 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/o3tl/safeint.hxx12
1 files changed, 9 insertions, 3 deletions
diff --git a/include/o3tl/safeint.hxx b/include/o3tl/safeint.hxx
index c2610edacec6..522eb166912b 100644
--- a/include/o3tl/safeint.hxx
+++ b/include/o3tl/safeint.hxx
@@ -239,11 +239,17 @@ make_unsigned(T value)
// tools like -fsanitize=implicit-conversion should still be able to detect truncation:
template<typename T1, typename T2> constexpr T1 narrowing(T2 value) { return value; }
-// std::min wrapped to inform coverity that the result is now deemed sanitized
+// inform coverity that the returned value is now deemed sanitized
// coverity[ -taint_source ]
-template<typename T> inline T sanitizing_min(T a, T b)
+template<typename T> [[nodiscard]] inline T deem_sanitized(T a)
+{
+ return a;
+}
+
+// std::min wrapped to inform coverity that the result is now deemed sanitized
+template<typename T> [[nodiscard]] inline T sanitizing_min(T a, T b)
{
- return std::min(a, b);
+ return o3tl::deem_sanitized(std::min(a, b));
}
}