quite a few python panels (10 or so) had names longer then the PanelType allowed,

for panels it would fail silently but for menu's it meant further references would give errors.

increase the registered class name from 32 to 64 and raise an error if the limit reached.
This commit is contained in:
Campbell Barton 2009-12-22 10:04:15 +00:00
parent 8f5b2e946b
commit e207d04532
5 changed files with 34 additions and 5 deletions

@ -55,7 +55,7 @@ struct uiMenuItem;
ED_spacetypes_init() in editors/area/spacetypes.c */ ED_spacetypes_init() in editors/area/spacetypes.c */
/* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */ /* an editor in Blender is a combined ScrArea + SpaceType + SpaceData */
#define BKE_ST_MAXNAME 32 #define BKE_ST_MAXNAME 64
typedef struct SpaceType { typedef struct SpaceType {
struct SpaceType *next, *prev; struct SpaceType *next, *prev;

@ -205,6 +205,15 @@ StructRNA *rna_IDPropertyGroup_register(const bContext *C, ReportList *reports,
if(validate(&dummyptr, data, NULL) != 0) if(validate(&dummyptr, data, NULL) != 0)
return NULL; return NULL;
/* note: it looks like there is no length limit on the srna id since its
* just a char pointer, but take care here, also be careful that python
* owns the string pointer which it could potentually free while blender
* is running. */
if(strlen(identifier) >= sizeof(((IDProperty *)NULL)->name)) {
BKE_reportf(reports, RPT_ERROR, "registering id property class: '%s' is too long, maximum length is %d.", identifier, sizeof(((IDProperty *)NULL)->name));
return NULL;
}
return RNA_def_struct(&BLENDER_RNA, identifier, "IDPropertyGroup"); // XXX return RNA_def_struct(&BLENDER_RNA, identifier, "IDPropertyGroup"); // XXX
} }

@ -126,6 +126,11 @@ static StructRNA *rna_RenderEngine_register(const bContext *C, ReportList *repor
if(validate(&dummyptr, data, have_function) != 0) if(validate(&dummyptr, data, have_function) != 0)
return NULL; return NULL;
if(strlen(identifier) >= sizeof(dummyet.idname)) {
BKE_reportf(reports, RPT_ERROR, "registering render engine class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummyet.idname));
return NULL;
}
/* check if we have registered this engine type before, and remove it */ /* check if we have registered this engine type before, and remove it */
for(et=R_engines.first; et; et=et->next) { for(et=R_engines.first; et; et=et->next) {
if(strcmp(et->idname, dummyet.idname) == 0) { if(strcmp(et->idname, dummyet.idname) == 0) {

@ -164,6 +164,11 @@ static StructRNA *rna_Panel_register(const bContext *C, ReportList *reports, voi
if(validate(&dummyptr, data, have_function) != 0) if(validate(&dummyptr, data, have_function) != 0)
return NULL; return NULL;
if(strlen(identifier) >= sizeof(dummypt.idname)) {
BKE_reportf(reports, RPT_ERROR, "registering panel class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummypt.idname));
return NULL;
}
if(!(art=region_type_find(reports, dummypt.space_type, dummypt.region_type))) if(!(art=region_type_find(reports, dummypt.space_type, dummypt.region_type)))
return NULL; return NULL;
@ -261,6 +266,11 @@ static StructRNA *rna_Header_register(const bContext *C, ReportList *reports, vo
if(validate(&dummyhtr, data, have_function) != 0) if(validate(&dummyhtr, data, have_function) != 0)
return NULL; return NULL;
if(strlen(identifier) >= sizeof(dummyht.idname)) {
BKE_reportf(reports, RPT_ERROR, "registering header class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummyht.idname));
return NULL;
}
if(!(art=region_type_find(reports, dummyht.space_type, RGN_TYPE_HEADER))) if(!(art=region_type_find(reports, dummyht.space_type, RGN_TYPE_HEADER)))
return NULL; return NULL;
@ -374,6 +384,11 @@ static StructRNA *rna_Menu_register(const bContext *C, ReportList *reports, void
if(validate(&dummymtr, data, have_function) != 0) if(validate(&dummymtr, data, have_function) != 0)
return NULL; return NULL;
if(strlen(identifier) >= sizeof(dummymt.idname)) {
BKE_reportf(reports, RPT_ERROR, "registering menu class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummymt.idname));
return NULL;
}
/* check if we have registered this menu type before, and remove it */ /* check if we have registered this menu type before, and remove it */
mt= WM_menutype_find(dummymt.idname, TRUE); mt= WM_menutype_find(dummymt.idname, TRUE);
if(mt && mt->ext.srna) if(mt && mt->ext.srna)

@ -253,8 +253,8 @@ typedef struct RenderEngineType {
struct RenderEngineType *next, *prev; struct RenderEngineType *next, *prev;
/* type info */ /* type info */
char idname[32]; char idname[64]; // best keep the same size as BKE_ST_MAXNAME
char name[32]; char name[64];
int flag; int flag;
void (*render)(struct RenderEngine *engine, struct Scene *scene); void (*render)(struct RenderEngine *engine, struct Scene *scene);