changeset 30886:05328c2145ff stable

* graphics.cc (convert_position): Avoid possible buffer overflow.
author John W. Eaton <jwe@octave.org>
date Mon, 04 Apr 2022 00:20:10 -0400
parents 0a1aec50a0c8
children 4bab8d3fce79 41101f2facdc
files libinterp/corefcn/graphics.cc
diffstat 1 files changed, 1 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc	Sun Apr 03 11:29:17 2022 -0400
+++ b/libinterp/corefcn/graphics.cc	Mon Apr 04 00:20:10 2022 -0400
@@ -694,7 +694,7 @@
 convert_position (const Matrix& pos, const caseless_str& from_units,
                   const caseless_str& to_units, const Matrix& parent_dim)
 {
-  Matrix retval (1, pos.numel ());
+  Matrix retval (1, pos.numel (), 0.0);
   double res = 0;
   bool is_rectangle = (pos.numel () == 4);
   bool is_2D = (pos.numel () == 2);
@@ -829,8 +829,6 @@
             }
         }
     }
-  else if (! is_rectangle && ! is_2D)
-    retval(2) = 0;
 
   return retval;
 }