Browse Source

Merge pull request #64235 from tinmanjuggernaut/gles2_free_abuse

Fix free(RID) abuse by various classes
lawnjelly 3 years ago
parent
commit
196201d6f1
3 changed files with 12 additions and 4 deletions
  1. 3 1
      scene/2d/particles_2d.cpp
  2. 6 2
      scene/3d/gi_probe.cpp
  3. 3 1
      scene/3d/particles.cpp

+ 3 - 1
scene/2d/particles_2d.cpp

@@ -419,5 +419,7 @@ Particles2D::Particles2D() {
 }
 
 Particles2D::~Particles2D() {
-	VS::get_singleton()->free(particles);
+	if (particles.is_valid()) {
+		VS::get_singleton()->free(particles);
+	}
 }

+ 6 - 2
scene/3d/gi_probe.cpp

@@ -179,7 +179,9 @@ GIProbeData::GIProbeData() {
 }
 
 GIProbeData::~GIProbeData() {
-	VS::get_singleton()->free(probe);
+	if (probe.is_valid()) {
+		VS::get_singleton()->free(probe);
+	}
 }
 
 //////////////////////
@@ -527,5 +529,7 @@ GIProbe::GIProbe() {
 }
 
 GIProbe::~GIProbe() {
-	VS::get_singleton()->free(gi_probe);
+	if (gi_probe.is_valid()) {
+		VS::get_singleton()->free(gi_probe);
+	}
 }

+ 3 - 1
scene/3d/particles.cpp

@@ -416,5 +416,7 @@ Particles::Particles() {
 }
 
 Particles::~Particles() {
-	VS::get_singleton()->free(particles);
+	if (particles.is_valid()) {
+		VS::get_singleton()->free(particles);
+	}
 }