From c91b5dc488525fe0adb529f49df2f5b9bb2855c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Mon, 2 Sep 2024 14:27:14 +0200 Subject: [PATCH] Avoid integer underflow with unsigned integers. * liboctave/util/lo-regexp.cc (regexp::compile_internal): Avoid comparing difference of unsigned integers with 0. Fixes: https://github.com/gnu-octave/octave/security/code-scanning/42 --- liboctave/util/lo-regexp.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liboctave/util/lo-regexp.cc b/liboctave/util/lo-regexp.cc index 1b14ff629b..809adc3f42 100644 --- a/liboctave/util/lo-regexp.cc +++ b/liboctave/util/lo-regexp.cc @@ -175,7 +175,7 @@ regexp::compile_internal () m_names++; } - if (new_pos - pos > 0) + if (new_pos > pos) buf << m_pattern.substr (pos, new_pos-pos); if (inames < 10) buf << "(?P