changeset 27772:2d1af61d8f5e stable

Fix segfault in constructing patch normals for lighting (bug #57353). * graphics.cc (patch::properties::calc_face_normals, patch::properties::update_vertex_normals): Check that "nc < max_nc" BEFORE indexing in to faces with nc.
author Rik <rik@octave.org>
date Wed, 04 Dec 2019 12:01:45 -0800
parents f998e243fa78
children 54767f6a93f5 088d5e7a2b7e
files libinterp/corefcn/graphics.cc
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc	Wed Nov 13 11:11:49 2019 +0100
+++ b/libinterp/corefcn/graphics.cc	Wed Dec 04 12:01:45 2019 -0800
@@ -9636,7 +9636,7 @@
       octave_idx_type nc = 3;
       if (max_nc > 3)
         {
-          while (! octave::math::isnan (f(i,nc)) && nc < max_nc)
+          while (nc < max_nc && ! octave::math::isnan (f(i,nc)))
             nc++;
         }
 
@@ -9760,7 +9760,7 @@
           octave_idx_type nc = 3;
           if (max_nc > 3)
             {
-              while (! octave::math::isnan (f(i,nc)) && nc < max_nc)
+              while (nc < max_nc && ! octave::math::isnan (f(i,nc)))
                 nc++;
             }