Skip to content

Commit 5352638

Browse files
committed
Add some multimesh null checks to avoid crash
1 parent 4d1f26e commit 5352638

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

drivers/gles3/storage/mesh_storage.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,21 +535,25 @@ class MeshStorage : public RendererMeshStorage {
535535

536536
_FORCE_INLINE_ RS::MultimeshTransformFormat multimesh_get_transform_format(RID p_multimesh) const {
537537
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
538+
ERR_FAIL_NULL_V(multimesh, RS::MULTIMESH_TRANSFORM_3D);
538539
return multimesh->xform_format;
539540
}
540541

541542
_FORCE_INLINE_ bool multimesh_uses_colors(RID p_multimesh) const {
542543
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
544+
ERR_FAIL_NULL_V(multimesh, false);
543545
return multimesh->uses_colors;
544546
}
545547

546548
_FORCE_INLINE_ bool multimesh_uses_custom_data(RID p_multimesh) const {
547549
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
550+
ERR_FAIL_NULL_V(multimesh, false);
548551
return multimesh->uses_custom_data;
549552
}
550553

551554
_FORCE_INLINE_ uint32_t multimesh_get_instances_to_draw(RID p_multimesh) const {
552555
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
556+
ERR_FAIL_NULL_V(multimesh, 0);
553557
if (multimesh->visible_instances >= 0) {
554558
return multimesh->visible_instances;
555559
}
@@ -558,21 +562,25 @@ class MeshStorage : public RendererMeshStorage {
558562

559563
_FORCE_INLINE_ GLuint multimesh_get_gl_buffer(RID p_multimesh) const {
560564
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
565+
ERR_FAIL_NULL_V(multimesh, 0);
561566
return multimesh->buffer;
562567
}
563568

564569
_FORCE_INLINE_ uint32_t multimesh_get_stride(RID p_multimesh) const {
565570
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
571+
ERR_FAIL_NULL_V(multimesh, 0);
566572
return multimesh->stride_cache;
567573
}
568574

569575
_FORCE_INLINE_ uint32_t multimesh_get_color_offset(RID p_multimesh) const {
570576
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
577+
ERR_FAIL_NULL_V(multimesh, 0);
571578
return multimesh->color_offset_cache;
572579
}
573580

574581
_FORCE_INLINE_ uint32_t multimesh_get_custom_data_offset(RID p_multimesh) const {
575582
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
583+
ERR_FAIL_NULL_V(multimesh, 0);
576584
return multimesh->custom_data_offset_cache;
577585
}
578586

servers/rendering/renderer_rd/storage_rd/mesh_storage.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,26 +689,31 @@ class MeshStorage : public RendererMeshStorage {
689689

690690
_FORCE_INLINE_ bool multimesh_uses_indirect(RID p_multimesh) const {
691691
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
692+
ERR_FAIL_NULL_V(multimesh, false);
692693
return multimesh->indirect;
693694
}
694695

695696
_FORCE_INLINE_ RS::MultimeshTransformFormat multimesh_get_transform_format(RID p_multimesh) const {
696697
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
698+
ERR_FAIL_NULL_V(multimesh, RS::MULTIMESH_TRANSFORM_3D);
697699
return multimesh->xform_format;
698700
}
699701

700702
_FORCE_INLINE_ bool multimesh_uses_colors(RID p_multimesh) const {
701703
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
704+
ERR_FAIL_NULL_V(multimesh, false);
702705
return multimesh->uses_colors;
703706
}
704707

705708
_FORCE_INLINE_ bool multimesh_uses_custom_data(RID p_multimesh) const {
706709
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
710+
ERR_FAIL_NULL_V(multimesh, false);
707711
return multimesh->uses_custom_data;
708712
}
709713

710714
_FORCE_INLINE_ uint32_t multimesh_get_instances_to_draw(RID p_multimesh) const {
711715
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
716+
ERR_FAIL_NULL_V(multimesh, 0);
712717
if (multimesh->visible_instances >= 0) {
713718
return multimesh->visible_instances;
714719
}

0 commit comments

Comments
 (0)