Page MenuHome

Prevent crash when not supplying optional parameter to uv_on_emitter
ClosedPublic

Authored by Robert Guetzkow (rjg) on Jan 17 2021, 12:37 AM.

Details

Summary

This patch fixes T84588's second issue. The particle parameter is optional in the Python API of bpy.types.ParticleSystem.uv_on_emitter, however it isn't properly validated that it may be None. This lead to the dereferencing of a NULL-pointer in rna_ParticleSystem_tessfaceidx_on_emitter called by rna_ParticleSystem_uv_on_emitter. The fix is to add a NULL check and return a negative value like when the other pointers are NULL.

Diff Detail

Repository
rB Blender

Event Timeline

Robert Guetzkow (rjg) requested review of this revision.Jan 17 2021, 12:37 AM
Robert Guetzkow (rjg) created this revision.
Robert Guetzkow (rjg) edited the summary of this revision. (Show Details)Jan 17 2021, 12:38 AM

Seems like the error is actually in rna.

diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index c42d891c389..ab8c1b0bb3f 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -4016,7 +4016,7 @@ static void rna_def_particle_system(BlenderRNA *brna)
   RNA_def_function_flag(func, FUNC_USE_REPORTS);
   parm = RNA_def_pointer(func, "modifier", "ParticleSystemModifier", "", "Particle modifier");
   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
-  prop = RNA_def_pointer(func, "particle", "Particle", "", "Particle");
+  parm = RNA_def_pointer(func, "particle", "Particle", "", "Particle");
   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
   RNA_def_int(func, "particle_no", 0, INT_MIN, INT_MAX, "Particle no", "", INT_MIN, INT_MAX);
   RNA_def_int(func, "uv_no", 0, INT_MIN, INT_MAX, "UV no", "", INT_MIN, INT_MAX);

@Jacques Lucke (JacquesLucke) Will take another look at this tomorrow.

@Jacques Lucke (JacquesLucke) it looks like you're absolutely right and the parameter was never intended to be optional. I will update the patch accordingly.

Robert Guetzkow (rjg) updated this revision to Diff 33292.EditedJan 29 2021, 11:27 AM

The parameter was never intended to be optional, it was a mistake in the parameter's definition

This revision is now accepted and ready to land.Jan 29 2021, 11:33 AM