OpenSubdiv: Fix crash with empty mesh
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 22 Sep 2015 16:10:23 +0000 (21:10 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 22 Sep 2015 16:11:17 +0000 (21:11 +0500)
Reported by newbz in IRC, thanks!

source/blender/blenkernel/intern/CCGSubSurf_opensubdiv.c

index 006cebf457359d3afaadbc4b23f140b0329b6cfe..39669fd76d784d16248a3ae94f3bb065676c7f15 100644 (file)
@@ -314,9 +314,12 @@ int ccgSubSurf_getNumGLMeshBaseFaces(CCGSubSurf *ss)
        if (ss->osd_topology_refiner != NULL) {
                topology_refiner = ss->osd_topology_refiner;
        }
-       else {
+       else if (ss->osd_mesh != NULL) {
                topology_refiner = openSubdiv_getGLMeshTopologyRefiner(ss->osd_mesh);
        }
+       else {
+               return 0;
+       }
        return openSubdiv_topologyRefinerGetNumFaces(topology_refiner);
 }
 
@@ -327,9 +330,12 @@ int ccgSubSurf_getNumGLMeshBaseFaceVerts(CCGSubSurf *ss, int face)
        if (ss->osd_topology_refiner != NULL) {
                topology_refiner = ss->osd_topology_refiner;
        }
-       else {
+       else if (ss->osd_mesh != NULL) {
                topology_refiner = openSubdiv_getGLMeshTopologyRefiner(ss->osd_mesh);
        }
+       else {
+               return 0;
+       }
        return openSubdiv_topologyRefinerGetNumFaceVerts(topology_refiner, face);
 }