[Bf-blender-cvs] [b1492b76baf] master: Alembic: Fix bad allocation with invalid knots data

Sergey Sharybin noreply at git.blender.org
Mon May 18 11:50:43 CEST 2020


Commit: b1492b76bafd490ff6c9c9c6efdede9a756a16be
Author: Sergey Sharybin
Date:   Mon May 18 11:09:48 2020 +0200
Branches: master
https://developer.blender.org/rBb1492b76bafd490ff6c9c9c6efdede9a756a16be

Alembic: Fix bad allocation with invalid knots data

It is not impossible that the number of knots is stored wrong in the
file (for example, it will be 1 knot only).

This change fixes bad memory allocation and bad memory access in such
cases. It also fixes strict compiler warning which was mentioning that
the allocation size is wrong),

There isn't really the correct way of dealing with such situation, so
simply fall back to Blender's knots calculation.

Differential Revision: https://developer.blender.org/D7765

===================================================================

M	source/blender/io/alembic/intern/abc_reader_nurbs.cc

===================================================================

diff --git a/source/blender/io/alembic/intern/abc_reader_nurbs.cc b/source/blender/io/alembic/intern/abc_reader_nurbs.cc
index 10d9a35a8e1..5b9954b3ff6 100644
--- a/source/blender/io/alembic/intern/abc_reader_nurbs.cc
+++ b/source/blender/io/alembic/intern/abc_reader_nurbs.cc
@@ -71,7 +71,7 @@ bool AbcNurbsReader::valid() const
 
 static bool set_knots(const FloatArraySamplePtr &knots, float *&nu_knots)
 {
-  if (!knots || knots->size() == 0) {
+  if (!knots || knots->size() < 2) {
     return false;
   }



More information about the Bf-blender-cvs mailing list