# HG changeset patch # User Markus Mützel # Date 1709921813 -3600 # Fri Mar 08 19:16:53 2024 +0100 # Branch stable # Node ID 464d1dab3d9eba87fce8001537528f2e0c66596d # Parent b5ffc06b39b2e0c380cb61d801cc47a18cf40f49 Check that number of values in "facevertexcdata" is consistent in patch (bug #65431). * libinterp/corefcn/graphics.cc (patch::properties::update_data): Do not continue if the number of color values in the "facevertexcdata" property matches neither the number of faces nor the number of vertices of a patch object. diff -r b5ffc06b39b2 -r 464d1dab3d9e libinterp/corefcn/graphics.cc --- a/libinterp/corefcn/graphics.cc Fri Mar 08 08:19:52 2024 +0100 +++ b/libinterp/corefcn/graphics.cc Fri Mar 08 19:16:53 2024 +0100 @@ -9631,6 +9631,14 @@ return; } + // Check if number of color values matches number of faces or vertices + if (! fvc.isempty () && fvc.rows () != nfaces && fvc.rows () != nvert) + { + m_bad_data_msg = "number of facevertexcdata values matches " + "neither number of faces nor number of vertices"; + return; + } + // Replace NaNs if (idx.any_element_is_inf_or_nan ()) { @@ -9697,21 +9705,20 @@ if (fvc.rows () == nfaces || fvc.rows () == 1) { + // "facevertexcdata" holds color data per face or same color for all dv(0) = 1; dv(1) = fvc.rows (); dv(2) = fvc.columns (); cd = fvc.reshape (dv); } - else - { - if (! fvc.isempty ()) - { - dv(0) = idx.rows (); - dv(1) = nfaces; - dv(2) = fvc.columns (); - cd.resize (dv); - pervertex = true; - } + else if (! fvc.isempty ()) + { + // "facevertexcdata" holds color data per vertex + dv(0) = idx.rows (); + dv(1) = nfaces; + dv(2) = fvc.columns (); + cd.resize (dv); + pervertex = true; } // Build x,y,zdata and eventually per vertex cdata