changeset 30423:e658f400a30e stable

Fix possible lifetime issue (bug #61132). * libinterp/octave-value/ov.cc (make_range): Assign temporary value to variable with defined scope.
author Markus Mützel <markus.muetzel@gmx.de>
date Fri, 03 Dec 2021 08:37:20 +0100
parents 2033c05c9522
children a5ca02c0ed7d a51d2c4a25f4
files libinterp/octave-value/ov.cc
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/octave-value/ov.cc	Fri Dec 03 10:28:31 2021 -0500
+++ b/libinterp/octave-value/ov.cc	Fri Dec 03 08:37:20 2021 +0100
@@ -3037,14 +3037,15 @@
                     || limit.is_uint32_type () || limit.is_uint64_type ())
                    && increment.scalar_value () < 0;
 
+    octave_value inc = (reverse ? -increment : increment);
+
     check_colon_operand<T> (base, "lower bound");
-    check_colon_operand<T> ((reverse ? -increment : increment), "increment");
+    check_colon_operand<T> (inc, "increment");
     check_colon_operand<T> (limit, "upper bound");
 
     T base_val = octave_value_extract<T> (base);
 
-    T increment_val = octave_value_extract<T> (reverse ? -increment
-                                                       : increment);
+    T increment_val = octave_value_extract<T> (inc);
 
     T limit_val = octave_value_extract<T> (limit);